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: Nested switch viewhelper seems not working (in some cases) #428

Open
isikbattenstein opened this issue Feb 14, 2019 · 5 comments
Open
Labels

Comments

@isikbattenstein
Copy link

I created a cutom template for textmedia with a switch statement to load certain partials depending on layout.

At first I used the if viewhelper and everything worked fine. After I replaced the if viewhelper with the swich viewhelper, certain textmedias didn't load any more. After some research I found out that the header partial has to be the reason more concrete the switch statement inside header.

@tantegerda1
Copy link

I just tried different nested f:switch scenarios and could not reproduce your issue. Could you share a minimal template/variables combination that reliably reproduces the error?

@isikbattenstein
Copy link
Author

isikbattenstein commented Feb 18, 2019

I made a Textmedia Template, that looks like this:

 <f:switch expression="{data.layout}">
        <f:case value="0"><f:render partial="Textmedia/Default" arguments="{_all}"/></f:case>
        <f:case value="2"><f:render partial="Textmedia/TextInImage" arguments="{_all}"/></f:case>
        <f:case value="3"><f:render partial="Textmedia/List" arguments="{_all}"/></f:case>
        <f:case value="4"><f:render partial="Textmedia/PageHeader" arguments="{_all}"/></f:case>
        <f:case value="5"><f:render partial="Textmedia/TextBesidesImage" arguments="{_all}"/></f:case>
        <f:case value="6"><f:render partial="Textmedia/CenteredText" arguments="{_all}"/></f:case>
    </f:switch>

Some of these generates calls the "Header/All.html", but some not. Every Texemedia Partial that calls a header Element will not be rendered. I created a customized Partial Header.html, but it look mostly the same, I just added 3 cases:

   <f:case value="6">
            <h1 class="{positionClass} white text-shadow">
                <f:link.typolink parameter="{link}">{header}</f:link.typolink>
            </h1>
        </f:case>
        <f:case value="7">
            <h3 class="{positionClass} white">
                <f:link.typolink parameter="{link}">{header}</f:link.typolink>
            </h3>
        </f:case>
        <f:case value="8">
            <h2 class="{positionClass} white">
                <f:link.typolink parameter="{link}">{header}</f:link.typolink>
            </h2>
        </f:case>

That's what can I say for now.

@vertexvaar
Copy link
Contributor

vertexvaar commented Sep 3, 2019

I can reproduce this error.
Nested f:switch ViewHelpers sometimes fail to restore the "previous switch state" (The values of switchExpression and break in the ViewHelperVariableContainer).
When the previous break value is not restored to true the SwitchViewHelper will continue to render the defaultCase after rendering the case that actuall matched.

My working example is in the attached ZIP. Run composer install and test.php and you will see the output "CASE: Default". On the second run you will see "<h2 class="">Some header</h2>".
The bug is only reproducible when there is no cache thus the SwitchViewHelper is not compiled yet.

testfluid.zip [The folder cache has to be created manually]

I think the problem is somewhere in the recursion of the Header partial in the f:defaultCase CiewHelper (original taken from fluid_styled_content).

@hilburger
Copy link

Hi everybody!
I still get this on the latest 10.4.
Is the any news on this?
hanks!

@hilburger
Copy link

Could this be the same problem?
#514

@ohader ohader added the bug label Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants