b13/host-variants

Extends the base variants condition with current host.

Installs: 120 939

Dependents: 0

Suggesters: 0

Security: 0

Stars: 31

Watchers: 11

Forks: 4

Open Issues: 2

Type:typo3-cms-extension

1.2.0 2023-05-23 13:57 UTC

This package is auto-updated.

Last update: 2024-02-23 15:37:50 UTC


README

This extension allows to configure a base variant in TYPO3s Site Configuration depending on the current Host.

When is it useful?

This extension can be useful when dealing with multiple sites in one TYPO3 instance with different domains:

Let's say you have a primary domain primary-domain.tld with a site configuration. Backend editors log in to this primary domain.

You have a site config with an own page tree for a second domain another-domain.tld. Editors create content for the second domain on a hidden page. When previewing that page from within the backend, another-domain.tld/some-page-slug will be shown. Since editors are logged in to the primary domain, the backend user cookie will not be sent by the browser for the secondary domain, the frontend does not see a logged in backend user and will show a 404.

The extension now allows configuring a site base variant for the secondary domain that kicks in when backend preview is called from the main domain, and calls the frontend of the secondary site as a sub path of the main domain instead.

Requirements

  • TYPO3 9 LTS, 10 LTS, 11 LTS, 12 LTS

Installation and Setup

Install the extension via your preferred way. No further setup is required. The extension works out of the box.

What it does

The extension adds a variable host to the expression language for the Site Configuration. This allows configuring multiple domains for the same root page.

Example

Basic:

base: 'https://another-domain.tld/'
baseVariants:
  -
    base: 'https://primary-domain.tld/some-sub-path'
    condition: 'host == "primary-domain.tld"'

Using some ENV variable:

base: 'https://another-domain.tld/'
baseVariants:
  -
    base: 'https://%env(MAIN_DOMAIN)%/some-sub-path'
    condition: 'host == "%env(MAIN_DOMAIN)%"'

Combining conditions:

base: 'https://another-domain.tld/'
baseVariants:
  -
    base: 'https://local1.local/'
    condition: 'applicationContext == "Development" && host == "local1.local"'
  -
    base: 'https://local2.local/'
    condition: 'applicationContext == "Development" && host == "local2.local"'

Made by b13 with ♥

Find more TYPO3 extensions we have developed 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.