Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Render issue with <flux:content.render area="foo" /> in Workspace previews. #2158

Open
SimonMayr opened this issue Apr 11, 2024 · 1 comment

Comments

@SimonMayr
Copy link

I am using Flux Grid to render a Header on my Website. I have a Flux Configuration that looks like this:

<flux:grid>
    <flux:grid.row>
        <flux:grid.column name="headerItems" label="Header" colPos="1">
            <flux:form.variable name="allowedContentTypes" value="hwprovider_headeritem" />
        </flux:grid.column>
    </flux:grid.row>
</flux:grid>

and rendering it like this:

<flux:content.render area="headerItems" />

I am also using the Typo3 Workspace Module.

The issue i am facing is that if i move or edit the Header in a workspace, the Header-Items are missing in the Preview.
Specifically <flux:content.render area="headerItems" /> is not returning anything in the preview even tho there should be Header-Items.

Steps to reproduce the behavior:

  1. Switch to a Workspace other than the Live-Workspace.
  2. Edit or move a Content Element that has some "Child-Elements".
  3. Generate a preview link and visit the preview site.
  4. The "Child-Elements" are now missing in the preview.

I tested this in Typo3 v11 and v12 and with every version of this extension, and all versions had this issue.

If more information is needed, i can also provide some screenshots or try to explain the problem further.

Thanks for the time you guys put into this project.

Simon

@JanStorm
Copy link
Contributor

JanStorm commented Jan 27, 2025

I have encountered the same problem.
The Problem is that when rendering the content records of a workspace element, that they are identified by their colPos, which are based on the uid of the LIVE-element.

As example, we have these Elements:

  • a LIVE-version of a content element with the uid 42
  • a PREVIEW-Version of the same content element with the uid 43
  • The Live-Version contains 2 child column elements assigned with colPos 4201 and 4202 by the ColumnNumberUtility::calculateColumnNumberForParentAndColumn function.
  • A Element in Preview Workspace that results in a third column child with colPos 4203.

With this set, we render the preview element:
We see that the "placeholder" (the preview element) is used instead the original:

// Classes/ViewHelpers/Content/GetViewHelper.php
if ($workspaceId) {
    $placeholder = BackendUtility::getWorkspaceVersionOfRecord($workspaceId, 'tt_content', $record['uid'] ?? 0);
    if ($placeholder) {
        // Use the move placeholder if one exists, ensuring that "pid" and "tx_flux_parent" values are taken
        // from the workspace-only placeholder.
        /** @var array $record */
        $record = $placeholder;
    }
}

Rendering the preview results in the child elements being searched by colPos 4301, 4302, 4303, ... (Again, because of ColumnNumberUtility::calculateColumnNumberForParentAndColumn).
The Problem here is that we want to render also the live elements, which have the colPos 4201, 4201, ...

So as a solution, i kept that information about the original record and used it then to also check for rows in this live record:

diff --git a/Classes/ViewHelpers/Content/GetViewHelper.php b/Classes/ViewHelpers/Content/GetViewHelper.php
if ($workspaceId) {
    $placeholder = BackendUtility::getWorkspaceVersionOfRecord($workspaceId, 'tt_content', $record['uid'] ?? 0);
    if ($placeholder) {
        // Use the move placeholder if one exists, ensuring that "pid" and "tx_flux_parent" values are taken
        // from the workspace-only placeholder.
+       $liveRecord = $record;
        /** @var array $record */
        $record = $placeholder;
    }
}

/** @var AbstractProvider $provider */
$provider = $renderingContext->getViewHelperVariableContainer()->get(FormViewHelper::class, 'provider');
$grid = $provider->getGrid($record);
$rows = static::getContentRecords($arguments, $record, $grid);
+if (isset($liveRecord) && $liveRecord['uid'] !== $record['uid']) {
+  array_push($rows, ...static::getContentRecords($arguments, $liveRecord, $grid));
+}

This solves the issues, but im not sure whether thats the correct location to fix this. Maybe this can also be solved when saving the element.

JanStorm added a commit to JanStorm/flux that referenced this issue Jan 27, 2025
As described in Issue FluidTYPO3#2158 children are not rendered when previewing changes made in the preview workspace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants