Search code examples
typoscriptextbasetypo3-9.x

Handle multi domain setup with distribution extensions in TYPO3 9.5 LTS


I've got a multi domain setup in TYPO3 9.5.20 LTS and according to best practice experience I should use distribution extensions to offer Typoscript and the template to each root. So I did that.

domainA template contains:

  • fluid_styled_content
  • ...
  • gridelements
  • templatea

domainB template contains:

  • fluid_styled_content
  • ...
  • gridelements
  • templateb

The problem now is that in domainB I only see the BE layouts of domainA.

How can I separate that? How can I limit it to it's page?

I define the layout in Configuration/TSConfig/Page.txt with mod.web_layout.BackendLayouts. And in each extension I load that Page.txt in the ext_localconf.php like:

<?php
if (!defined('TYPO3_MODE')) {
    die ('Access denied.');
}

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
    '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:templatea/Configuration/TSConfig/Page.txt">'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
    '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:templatea/Configuration/TSConfig/User.txt">'
);

Of course I do templateb in domainB ;)


Side note: For tx_gridelements I've got a solution for that by adding that to the Page.txt:

# Limit the gridelements storage to a single page id
TCEFORM.tt_content.tx_gridelements_backend_layout.PAGE_TSCONFIG_ID = 1

But this limitation only works in domainA as well.


Solution

  • Okay the solution is very simple, once you know it. You don't add it with addPageTSConfig and not in ext_localconf.php. Just create a /Configuration/TCA/Overrides/pages.php and add:

    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile( 'myextkey', 'Configuration/TSConfig/Page.txt', 'Template domainA PageTSConfig' );

    After delete the cache go to your page settings to "Resources" and added via "Include Page TSconfig (from extensions)", save and voila.

    Documentation reference: https://docs.typo3.org/m/typo3/reference-tsconfig/master/en-us/UsingSetting/Index.html#using-and-setting-tsconfig