├── Classes └── ExpressionLanguage │ └── SiteConditionProvider.php ├── Configuration └── ExpressionLanguage.php ├── Readme.md ├── Resources └── Public │ └── Icons │ └── Extension.svg ├── composer.json └── ext_emconf.php /Classes/ExpressionLanguage/SiteConditionProvider.php: -------------------------------------------------------------------------------- 1 | expressionLanguageVariables = [ 24 | 'host' => GeneralUtility::getIndpEnv('HTTP_HOST'), 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Configuration/ExpressionLanguage.php: -------------------------------------------------------------------------------- 1 | [ 5 | \B13\HostVariants\ExpressionLanguage\SiteConditionProvider::class, 6 | ] 7 | ]; 8 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # EXT: host_variants 2 | 3 | This extension allows to configure a base variant in TYPO3s Site Configuration depending 4 | on the current Host. 5 | 6 | ## When is it useful? 7 | 8 | This extension can be useful when dealing with multiple sites in one TYPO3 instance 9 | with different domains: 10 | 11 | Let's say you have a primary domain `primary-domain.tld` with a site configuration. 12 | Backend editors log in to this primary domain. 13 | 14 | You have a site config with an own page tree for a second domain `another-domain.tld`. 15 | Editors create content for the second domain on a hidden page. When previewing that 16 | page from within the backend, `another-domain.tld/some-page-slug` will be shown. Since 17 | editors are logged in to the primary domain, the backend user cookie will not be sent by 18 | the browser for the secondary domain, the frontend does not see a logged in backend 19 | user and will show a 404. 20 | 21 | The extension now allows configuring a site base variant for the secondary domain that 22 | kicks in when backend preview is called from the main domain, and calls the frontend 23 | of the secondary site as a sub path of the main domain instead. 24 | 25 | 26 | ## Requirements 27 | 28 | * TYPO3 v11 LTS, v12 LTS or v13 LTS 29 | 30 | ## Installation and Setup 31 | Install the extension via your preferred way. No further setup is required. 32 | The extension works out of the box. 33 | 34 | ## What it does 35 | The extension adds a variable `host` to the expression language for the Site Configuration. 36 | This allows configuring multiple domains for the same root page. 37 | 38 | ## Example 39 | 40 | Basic: 41 | 42 | ```yaml 43 | base: 'https://another-domain.tld/' 44 | baseVariants: 45 | - 46 | base: 'https://primary-domain.tld/some-sub-path' 47 | condition: 'host == "primary-domain.tld"' 48 | ``` 49 | 50 | Using some ENV variable: 51 | 52 | ```yaml 53 | base: 'https://another-domain.tld/' 54 | baseVariants: 55 | - 56 | base: 'https://%env(MAIN_DOMAIN)%/some-sub-path' 57 | condition: 'host == "%env(MAIN_DOMAIN)%"' 58 | ``` 59 | 60 | Combining conditions: 61 | 62 | ```yaml 63 | base: 'https://another-domain.tld/' 64 | baseVariants: 65 | - 66 | base: 'https://local1.local/' 67 | condition: 'applicationContext == "Development" && host == "local1.local"' 68 | - 69 | base: 'https://local2.local/' 70 | condition: 'applicationContext == "Development" && host == "local2.local"' 71 | ``` 72 | 73 | --- 74 | 75 | 76 | _Made by [b13](https://b13.com) with ♥_ 77 | 78 | [Find more TYPO3 extensions we have developed](https://b13.com/useful-typo3-extensions-from-b13-to-you) that help us deliver value in client projects. As part of the way we work, we focus on testing and best practices to ensure long-term performance, reliability, and results in all our code. 79 | -------------------------------------------------------------------------------- /Resources/Public/Icons/Extension.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "b13/host-variants", 3 | "type": "typo3-cms-extension", 4 | "description": "Extends the base variants condition with current host.", 5 | "authors": [ 6 | { 7 | "name": "Daniel Goerz", 8 | "role": "Developer" 9 | } 10 | ], 11 | "license": ["GPL-2.0-or-later"], 12 | "require": { 13 | "typo3/cms-core": "^11.4 || ^12.0.0 || ^13.0.0" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "B13\\HostVariants\\": "Classes" 18 | } 19 | }, 20 | "extra": { 21 | "typo3/cms": { 22 | "extension-key": "host_variants" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ext_emconf.php: -------------------------------------------------------------------------------- 1 | 'Hosts Variants', 5 | 'description' => 'Extends the base variants condition with current host.', 6 | 'category' => 'fe', 7 | 'author' => 'Daniel Goerz', 8 | 'author_email' => 'daniel.goerz@b13.com', 9 | 'state' => 'stable', 10 | 'uploadfolder' => false, 11 | 'createDirs' => '', 12 | 'clearCacheOnLoad' => 1, 13 | 'author_company' => '', 14 | 'version' => '1.3.0', 15 | 'constraints' => [ 16 | 'depends' => [ 17 | 'typo3' => '11.5.0-13.4.99' 18 | ], 19 | 'conflicts' => [], 20 | 'suggests' => [], 21 | ] 22 | ]; 23 | --------------------------------------------------------------------------------