Expand tx_news TCA - typo3

I want to add a field in the backend of the new news module. For that I created a new extension with 3 files in it:
ext_emconf.php
<?php
$EM_CONF[$_EXTKEY] = array(
'title' => 'Expand news',
'description' => 'Expand news',
'category' => 'fe',
'author' => 'SOG',
'author_email' => '-',
'shy' => '',
'dependencies' => '',
'conflicts' => '',
'priority' => '',
'module' => '',
'state' => 'stable',
'internal' => '',
'uploadfolder' => 0,
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'author_company' => '',
'version' => '0.1.0',
'constraints' => array(
'depends' => array(
),
'conflicts' => array(
),
'suggests' => array(
),
),
'_md5_values_when_last_written' => '',
'suggests' => array(
),
);
?>
ext_tables.php
<?php
/*if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}*/
$tempColumns = array(
'tx_sogexpandnews_test' => array(
'exclude' => 0,
'label' => 'test',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
)
),
);
t3lib_div::loadTCA('tx_news_domain_model_news');
t3lib_extMgm::addTCAcolumns('tx_news_domain_model_news',$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes('tx_news_domain_model_news','tx_sogexpandnews_test', '', 'after:title'));
?>
ext_tables.sql
#
# Table structure for table 'news'
#
CREATE TABLE tx_news_domain_model_news (
tx_sogexpandnews_test text
);
The field is in the database but I dont see the field in the backend when I wanna create a new news item.
I also checked LocalConfiguation.php and made sure that my extension is under the news extension.
Any idea what I miss?

I can't tell why but I deactived news, updated it and installed it again and now I see the field.

cache - cache - cache ... always cache.
If you need to be sure, always delete everything in typo3temp and flush all cf_* tables in your db.
(deactivating and reinstalling almost does the same)

Related

TYPO3 8 dbal mapping with other server

I've a problem.
I just installed a new TYPO3 8 with adodb and dbal extensions.
Now I have an other server with a MySQLi Server and some custom tables in one database.
I want to show and edit the data from that other MySQLi Server Database Table named account in my TYPO3. For that, I have created my own extension with an model named tx_base_domain_model_account with as example 2 fields.
After that I created a dbal mapping with the following configuration:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'] = array(
'handlerCfg' => array(
'_DEFAULT' => array(
'type' => 'native',
'config' => array(
'driver' => 'mysqli'
)
),
'_otherServer' => array(
'type' => 'native',
'config' => array(
'username' => 'username',
'password' => 'password',
'host' => '192.168.177.XX',
'database' => 'account',
)
),
),
'table2handlerKeys' => array(
'account' => '_otherServer'
),
'debugOptions' => array(
'enabled' => true,
'printErrors' => true,
'EXPLAIN' => 1,
'parseQuery' => 1,
'joinTables' => 1
),
'mapping' => array(
'tx_base_domain_model_account' => array(
'mapTableName' => 'account',
'mapFieldNames' => array (
'uid' => 'id',
'pid' => 119,
'login' => 'login',
'password' => 'password',
'cruser_id' => 1
)
)
)
);
But I can't see, edit or whatever the data from that other server database table.
Can you help me?
Thank you
With the switch to doctrine-dbal in core v8, the core extensions 'dbal' and 'adodb' have been obsoleted. See https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Database/Configuration/Index.html for configuration details on how to map tables to a different dbms using doctrine-dbal.

Create custom module without bean to show up in menu

I am wondering how to create custom module in SugarCRM and show link into the menu bar. So my custom module will not be a Bean, but needs to be visible in menu bar.
My manifest.php file is as follows:
$manifest = array(
'acceptable_sugar_versions' => array(
"rege_matches" => array("5.1.*")
),
'acceptable_sugar_flavors' => array(
'CE'
),
'name' => 'CustomModule',
'version' => '1.0',
'description' => 'CustomModule for SugarCRM',
'author' => 'Community',
'published_date' => '2015/02/17',
'type' => 'module',
'icon' => 'icons/default/icon_CustomModule.gif',
'is_uninstallable' => 'true',
);
$installdefs = array(
'id'=> 'CustomModule',
'copy' => array (
array (
'from' => '<basepath>/package/CustomModule',
'to' => 'modules/CustomModule',
),
),
'language' => array(
array(
'language'=> 'en_us',
'from'=> '<basepath>/package/language/application/en_us.lang.php',
'to_module' => 'application',
'language' => 'en_us',
),
),
);
Thanks!

Setting default checked value in ZendFramework2 to RADIO input (QuickStart form)

Unfortunately i don`t have the exact example here, but, is similar to this:
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender'
'options' => array(
'label' => 'What is your gender ?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
)
));
How can I set a default value to this element? I tried putting this, but didn't work:
'attributes' => array(
'value' => '0'
)
Thank's! And, sorry for my poor english! I need to improve it!
You should provide the value underoption, not attribute.
LIke this :
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender'
'options' => array(
'label' => 'What is your gender ?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
'value' => 10, // here
)
));
See this link:here
Radio is just an extension of MultiCheckbox
You will need to set the checked_value within the options array
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender', // <-- missing comma here also
'options' => array(
'label' => 'What is your gender ?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
'checked_value' => 10,
)
));
You can see this in the setOptions() method of Zend\Form\Element\Checkbox which the Radio element extends.
Your syntax is correct. value key in attributes is used to set the default checked value.
You just forgot to add a comma after 'name' => 'gender'
The following code will work for you
$form->add(array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'gender',
'attributes' => array(
'value' => '0',
),
'options' => array(
'label' => 'What is your gender?',
'value_options' => array(
'0' => 'Female',
'1' => 'Male',
),
),
));

Typo3, TCA forms view depending on the chosen option

I have made in backend a TCA form, what will change depending of the value in select field "type":
This select field contains basically the options:
rte text
url
picture
I can make the system working so, that when "rte text" is chosen, it shows specified fields for "rte text", when url is chosen it shows specified fields for "url" etc..
In my case the content is always saved in database in field "content" and the selected type is saved in field "type".
My problem is that I have not found a way to change the "content" form field / configuration, depending on the selected type.
For example when I choose "rte text" it should use for the content field this kind of configuration (rich text editor):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
and when I choose "picture" it should use for the content field this kind of configuration (file uploader):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
Is there a way to change that configuration depending of the value in the selectbox. I have tried to put two contents in an array but haven't got it working on that way.
Unfortunately you cannot change the properties of a single field via type.
You can however influence what's being displayed. So you can configure two independent fields and switch the display:
ext_tables.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => array(
//...
'type'=>'type',
//...
),
);
TCA.php:
$TCA['tx_yourextension_yourtable'] = array(
'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'],
'types' => array(
0 => array('showitem' => 'content_rte'),
1 => array('showitem' => 'content_image'),
),
'columns' => array(
'content_rte' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
'content_upload' => array(
'exclude' => 0,
'label' => 'Content',
'config' => array(
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
),
// ...
);
(Note: I've removed system fields like hidden, sys_language_uid etc. for simplicity's sake)

how to set up a zend multiCheckbox form field with the checkboxes checked?

i have this form:
$this->addElement (
'multiCheckbox', 'servers2',
array (
'checkedValue' => '0',
'multiOptions' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
));
the problem is that the checkedValue doesn't work for this setup, it does for a simple checkbox. I've also tried 'checkedValues' => array('1','0'), singular or plural,
but no end in sight.
any ideas?
THanks
To mark certain checkboxes as checked, try this:
$multiCheckElement->setValue(array('11.com', '3.com'));
// or
$this->addElement (
'multiCheckbox', 'servers2',
array (
'value' => array('11.com', '3.com'), // select these 2 values
'multiOptions' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
)
);
See also Zend_Form_Element_MultiCheckbox
ZF2 will require you to use value_options;
$form->add(
array(
'name' => 'servers2',
'type' => \Zend\Form\Element\MultiCheckbox::class,
'attributes' => array(
'id' => 'servers2',
'class' => 'form-control',
),
'options' => array(
'label' => 'Servers 2',
'column-size' => 'sm-10',
'label_attributes' => array('class' => 'col-sm-2'),
'twb-layout' => 'horizontal',
'value_options' => array(
'11.com' => '.com',
'12.com' => '12.com',
'16.com' => '16.com',
'3.com' => '17.com'
)
),
)
);
To specify the checked options, as seen at
use the 'selected' => true attribute:
$options = array(
array(
'value' => '0',
'label' => 'Apple',
'selected' => false,
'disabled' => false,
'attributes' => array(
'id' => 'apple_option',
'data-fruit' => 'apple',
),
'label_attributes' => array(
'id' => 'apple_label',
),
),
array(
'value' => '1',
'label' => 'Orange',
'selected' => true,
),
array(
'value' => '2',
'label' => 'Lemon',
),
);