Add custom elements to TYPO3 as hidden by default? - typo3

I have an installation with multiple websites. Each site has a site package with custom fields and content elements that are specific to that site.
But the custom fields and content elements are shown on all sites.
In tt_content.php I add a custom element to the type dropdown. How can I make it hidden, then enable it in ts config for the page tree that it is used for?
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'Banner',
'my_extension_banner',
'EXT:core/Resources/Public/Icons/T3Icons/content/content-image.svg'
],
'textmedia',
'after'
);
Likewise, I have some custom fields added to existing elements. How can I make this field hidden unless specifically enabled by the ts config of the page that it is made for?
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'headers',
'--linebreak--,my_extension_myfield',
'after:subheader'
);

After some trial and error, I found that I can remove elements and fields globally by adding this to my ext_localconf.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
#Remove Custom Content Elements
TCEFORM.tt_content.CType.removeItems := addToList(my_extension_banner)
#Remove Custom Fields
TCEFORM.tt_content {
my_extension_myfield.disabled = 1
}
');
Then add them in again with my page specific ts config file PageTSConfig.tsconfig
#Add Custom Content Elements
TCEFORM.tt_content.CType.removeItems := removeFromList(my_extension_banner)
#Add Custom Fields
TCEFORM.tt_content {
my_extension_myfield.disabled = 0
}

I don't know if I understand the problem correctly, but you could place Page TsConfig in the root page of any web page and then hide the fields accordingly:
TCEFORM.pages {
subtitle.disabled = 1
}

Related

How can I set the icon for a content element in TYPO3?

In tt_content I have added something like this, and set the core icon 'content-image':
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'My Element',
'myelement',
'content-image'
],
'textmedia',
'after'
);
And this works in the 'Type' dropdown menu. However, when in Page or List view it always shows the default text icon. How do I change this to match the type menu?
Just found another question with a real good answer - mainly the same
as mine, but better structured - have a look:
How to setup icons for content elements or plugins in a TYPO3 extension
You may revisit https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html with a full overview.
The \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem() registers the icon only for the select field.
For the "new content element" wizard you have to provide a proper TSconfig part https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html#add-it-to-the-new-content-element-wizard
// example - you must adopt for your element
mod.wizards.newContentElement.wizardItems {
// add the content element to the tab "common"
common {
elements {
examples_newcontentelement {
iconIdentifier = content-text
title = LLL:EXT:examples/Resources/Private/Language/locallang.xlf:examples_newcontentelement_title
description = LLL:EXT:examples/Resources/Private/Language/locallang.xlf:examples_newcontentelement_description
tt_content_defValues {
CType = examples_newcontentelement
}
}
}
show := addToList(examples_newcontentelement)
}
}
If you want to use a custom image, you have to register it. Either in ext_localconf.php with proper icon calls or depending on the core version with the simple Configuration/Icons.php file.
See for 11.5+ https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Icon/Index.html or before see https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/Icon/Index.html
The next part is then TCA configuration for the specific table. Generic table icon file is configured with:
// or $GLOBALS if done as TCA Override for a existing table
return [
// ...
'ctrl' => [
'iconFile' => '',
// ...
],
// ...
https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/Iconfile.html
Table with types can have different icons per types, which can be set with typeicon_classes
https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Ctrl/Properties/TypeiconClasses.html#ctrl-reference-typeicon-classes - however, this depends on the type field. For tt_content this is "CType". So this helps only for real content elements which registeres as own CType - and not as list CType with a subtype list_type. For extbase plugin this is done with the proper plugin registration in Configuration/TCA/Overrides/tt_content.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'ExtkeyInCamelCase',
'PluginIdentifier',
'plugin title',
// icon
'my-icon');

Typo3 Content Elements missing in wizard

I have some content elements in a site package which I want to show up in the content element wizard as explained here:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentElements/ContentElementsWizard.html
Basically I have done the same as shown in the section "Create a new tab"
Configuration\TsConfig\Page\ContentElement\All.tsconfig is looking like this:
mod.wizards.newContentElement.wizardItems.mci.header = MCI
mod.wizards.newContentElement.wizardItems.mci {
elements {
mci_home_banner {
iconIdentifier = home-banner
title = Home-Banner
description = Banner der Startseite
tt_content_defValues.CType = mci_home_banner
}
mci_home_banner_element {
iconIdentifier = home-banner-element
title = Home Banner Element
description = Element im Starseitenbanner
tt_content_defValues.CType = mci_home_banner_element
}
}
show := addToList(mci_home_banner, mci_home_banner_element)
}
I reduced the code to just 2 elements. They are not shown at all, but are available over the dropdown, so I can switch to one of them after choosing another element.
This didn't work when created in 9.5 and still does not work after switching to version 11.5.10
What am I missing?
#user414873 Did you try to add your custom elements to the "common" tab instead of your new one "mci"?
And did you try to use an existing icon identifier (e.g. "content-image" or an other one - see https://typo3.github.io/TYPO3.Icons/)? Just to make sure that there is no problem with your custom icons that prevents the elements from being displayed.
Does this minimal example work for you:
mod.wizards.newContentElement.wizardItems.common {
elements {
mci_home_banner {
iconIdentifier = content-image
title = Home-Banner
description = Banner der Startseite
tt_content_defValues.CType = mci_home_banner
}
}
show := addToList(mci_home_banner)
}
And I would doubt this:
I guess otherwise the content elements wouldn't be available at all.
I suggest you check it's correctly included by using the "Info" module in your TYPO3 main menu. Then select the page where the content element should be included and switch the dropdown on top of the content area to "View TSconfig fields content". Now you can search for "wizards" and check if your element is included.

Is it possible to reorganize the default CEs in another Groups?

I would like to group several default typo3 CE into one group.
Is it possible?
The New Content Element Wizard can be changed with Page TSconfig. For example if you want the content element type html in the first tab, you can do the following:
mod.wizards.newContentElement.wizardItems.common {
elements {
html < mod.wizards.newContentElement.wizardItems.special.elements.html
}
show := addToList(html)
}
You can add a tab and fill it with an existing element like this:
mod.wizards.newContentElement.wizardItems.myTab {
header = My tab
elements {
html < mod.wizards.newContentElement.wizardItems.special.elements.html
}
show = html
}
To remove the existing type from its original tab, add:
mod.wizards.newContentElement.wizardItems.special.show := removeFromList(html)
More on this you can find here: https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/Mod.html#newcontentelement-wizarditems

How to add condition for a field in the layout of SuiteCRM.?

In that in studio I have created some fields in one module and i also add those fields in Layout. but i want to display the fields according to the selection, for example: if user select option-1 from dropdown field then it has to display say only three field, and if user select option-2 from dropdown field then it has to display say six fields. so i need to add some condition in the layout field. but i can't find any option there.. please help me to find out.
i also attached the example image below.
If you are using sugar 7.6 I can help,
You want to change the fields according to drop down values if i am not wrong .
For that you have to right a code in "record.js" and "create-actions.js" files . just write a js function.
This is an example for crerate-action.js
({
extendsFrom: 'CreateActionsView',
initialize: function (options) {
this.model.on("change:dropdown", this.renderFields, this);
},
renderFields: function () {
// write your code here
},
})
You need to modify the view definitions to add a script into the edit view of your module.
Example:
$viewdefs ['<Module Name>'] =
array(
'<View Name>View' =>
array(
'templateMeta' =>
array(
...
'includes' =>
array(
0 =>
array(
'file' => 'path/to/your/script.js',
),
1 =>
array(
'file' => 'path/to/your/script.js',
),
),
...
),
...
),
...
);
You then can use jQuery or any javascript library to hide or show the fields. if you are using SuiteR or SuiteP theme you can simply add/remove the hidden class to the elements.
Just make sure that you add all the fields into your view which you wish to show or hide.
To make this upgrade save modify or create
custom/modules/module name/metadata/editviewdefs.php for the edit view
custom/modules/module name/metadata/detailviewdefs.php for the detail view
There are many defined ways in sugarcrm, as you have created new fields, all you need to add dependencies on those fields like
$dictionary['YOUR_MODULE_NAME']['fields']['YOUR_FIELD_NAME']['dependency']='(equal($YOUR_DROPDOWN,"OPTION_1"))
see
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.7/Architecture/Sugar_Logic/Dependency_Actions/SetVisibility/#Visibility_Dependencies_in_Field_Definitions
This can also be added through Studio.
Go to Studio > module > fields > YOUR_FIELD > Dependent and add dependency.

How to change Typo3 Backend layout Name using TypoScript?

By default typo3 Back end layout give Normal,Left,Right and Border.
To hide the blocks i used following code
mod.SHARED.colPos_list = 0,1,2
How to rename the blocks in Typo script:
Normal - Description
Left- News
Right - Publications
Border - Footer
When inserting the following in the Page TSConfig of the root page, the values of the dropdown "Columns" are changed when editing content elements:
TCEFORM.tt_content.colPos.altLabels {
0 = News
1 = Description
2 = Publications
3 = Footer
}
Unfortunately, this is only halfway :(
According to Spalten ändern und umbenennen you'll need to edit typo3conf/extTables.php which affects all pages in the tree:
t3lib_extMgm::addPageTSConfig('
mod.SHARED.colPos_list = 0,1,2,3
');
$TCA["tt_content"]["columns"]["colPos"]["config"]["items"] = array (
"1" => array ("News||||||||||","1"),
"0" => array ("Description||||||||||","0"),
"3" => array ("Publications||||||||||","3"),
"2" => array ("Footer||||||||||","2"),
);
If you're using TYPO3 4.5+, you can use the new feature called backend layout or grid view.
It is very easy to use. You don't have to edit PHP-code. You just have to configure it using a wizard.
Joey Hasenau has written a good article at news.typo3.org about how to use the backend layout.
I hope, this facilitates your daily work!