My multisite install of TYPO3 has individual base domains for each of the frontend sites, such as https://frontend-website-1.example.org/, but backend users can generally manage multiple sites so all access to the backend is through a single shared domain, such as https://typo3.example.com/typo3/.
The Page module in the backend provides a preview option "View" or "View webpage" which opens in a new tab. I'd like backend users to be able to preview changes in workspaces and pages which are not yet live.
With just my base URL defined in site config, the preview opens on frontend-website-1.example.org where my backend user has no cookies set, so they see a 404 page. The domains do not share a common suffix so I can't use the same cookie domain for both.
I've added a base variant for my specific backend domain so all the sites can be previewed.
base: 'https://frontend-website-1.example.org/'
baseVariants:
- { base: /frontend-website-1/, condition: '...' }
The condition applicationContext == "Development" or like(host, "typo3.*")
has no effect on the live sites but means previews open at https://typo3.example.com/frontend-website-1/ which is ideal. However it has a side effect my editors do not like. When they edit a page in the backend, the Web Address is prefixed with /frontend-website-1 instead of their domain name.
Replacing the condition with applicationType == "frontend" and (applicationContext == "Development" or like(host, "typo3.*"))
fixes both problems in TYPO3 version 11. The preview is considered frontend type and loads https://typo3.example.com/frontend-website-1/ whereas the page form is considered backend type and displays the standard base prefix.
In version 12 this expression no longer has the same effect. The preview appears to now be considered backend type so both the preview and the form load typo3.example.com.
How can I have a different base variant for previews and backend forms which works in version 12?
It's possible to provide a user function to generate the prefix on the slug input box using TCA.
Something like this is enough for a simple use case. I'm working on a more detailed solution which allows for other slug prefix user functions to be called first.
<?php
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSlug;
final class SlugPrefix
{
public function getPrefix(array $parameters, TcaSlug $reference): string
{
return $parameters['site']->getConfiguration()['base'];
}
}