0

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'
);
user500665
  • 1,220
  • 1
  • 12
  • 38
  • 1
    You can try to create different elements pageTs files for each content element using `mod.wizards.newContentElement.wizardItems` and add `\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig` each content element pageTs config files, this will allow you to add pageTs selection from backend. – Ravi Sachaniya Nov 05 '19 at 12:35
  • @RaviSachaniya I already have the element in the wizard and that works good. But the elements added to the type dropdown in tt_content.php appear on every page. And the custom fields added to existing element also appear on every page. – user500665 Nov 05 '19 at 19:27

2 Answers2

2

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
}
user500665
  • 1,220
  • 1
  • 12
  • 38
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
}
Lazinbee
  • 163
  • 1
  • 5
  • Basically I want to do the opposite. When I add a custom field I want it hidden in all pages by default. Then show it on the page tree it is made for. And I want the same for custom content elements in the type dropdown menu. – user500665 Nov 05 '19 at 19:23