Photo of Torben Hansen

A TechBlog by Torben Hansen


Freelance Full Stack Web Developer located in Germany.
I create web applications mainly using TYPO3, PHP, Python and JavaScript.
Home Archive Tags

How to use flux and container extension in one TYPO3 system

TYPO3 is well known for its flexibility, extensibility, and sustainability. It is not uncommon to find TYPO3 installations that were originally built many years ago and which are still actively maintained and updated today. In some of those older setups, site layouts and content elements were implemented using the wellknown flux extension.

As TYPO3 has evolved, so have the also available technologies. Today TYPO3 integrators usually use TYPO3 core content elements, content_blocks and container to provide website layouts and content.

Why use flux and container extension in one TYPO3 system?

In longterm running multi-site TYPO3 systems, it may be required to use different technological approaches across individual sites. Some sites may rely on flux, while newer ones might use container. However, using both extensions within the same TYPO3 system is not possible out of the box, as they both override the itemsProcFunc for the colPos field of the tt_content table. This usually results in problems when adding new content elements to structured content elements which have content columns as shown in the image below.

Missing label for colPos field

The issue tracker of the container extension has several closed issues (example) related to this problem. I, however, could not find any issue with a solution on how to solve this problem on a site basis in one TYPO3 system.

Creating an own itemsProcFunc to handle both extensions

In this issue in the issue tracker of the container extension I found a hint on how to resolve the problem. Other than shown, I just need to ensure to apply the itemsProcFunc of each extension depending on the current site.

Important: First it has to be ensured, that my custom itemsProcFunc is loaded after the flux and container extension is loaded. To do so, I added dependencies to both extensions in the composer.json of my sitepackage extension.

Next, I registerted a custom itemsProcFunc in ext:sitepackage/Configuration/TCA/Overrides/tt_content.php as shown below:

$GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['itemsProcFunc'] = \Vender\Extension\UserFunc\ItemProcFunc::class . '->colPos';

Next, I created a new class ItemProcFunc in ext:sitepackage/Classes/UserFunc/ItemProcFunc.php as shown below:

<?php

namespace Vendor\Extension\UserFunc;

use FluidTYPO3\Flux\Integration\Overrides\BackendLayoutView;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ItemProcFunc
{
    public function colPos(array $parameters): void
    {
        $fluxSites = ['site1', 'site2', 'site3'];

        /** @var Site|null $site */
        $site = $parameters['site'] ?? null;
        if (!$site) {
            return;
        }

        if (in_array($site->getIdentifier(), $fluxSites, true)) {
            // ItemProcFunc for ext:flux sites
            $itemsProcFunc = GeneralUtility::makeInstance(BackendLayoutView::class);
            $itemsProcFunc->colPosListItemProcFunc($parameters);
        } else {
            // ItemProcFunc for ext:container sites
            $itemsProcFunc = GeneralUtility::makeInstance(\B13\Container\Tca\ItemProcFunc::class);
            $itemsProcFunc->colPos($parameters);
        }
    }
}

So basically, the function just checks if the current site is part of the list of flux sites and calls the appropriate itemsProcFunc of the corresponding extension.

Having the custom itemsProcFunc in place, I can now use both extensions in one TYPO3 system for individual sites.