Search code examples
phptypo3-8.xtypo3-extensions

TYPO3 Frontend Error: The ViewHelper "<v:switch>" could not be resolved


Trying to open a site including a html-file from my extension, this error occures: (TYPO3 Version 8.7.19)

1407060572: Fluid parse error in template 
partial_Video/VideoSlide_016cfc0cd210899384d5d10b02b3336b438691df, line 47 at 
character 1. Error: The ViewHelper "<v:switch>" could not be resolved. Based on 
your spelling, the system would load the class 
"FluidTYPO3\Vhs\ViewHelpers\SwitchViewHelper", however this class does not 
exist. (error code 1407060572). Template source chunk: <v:switch value=" 
{fegroup.uid}">

According to the error message, there is a problem with the Viewhelper and the switch statement.

Here is the using namespace

{namespace v=FluidTYPO3\vhs\ViewHelpers}

and here is the code of the switch statement:

<f:if condition="{v:variable.get(name: 'access', useRawKeys: 1)}">
    <!-- ... -->
    <f:else>
        <f:for each="{video.fegroupUID}" as="fegroup" iteration="iterator">
            <v:switch value="{fegroup.uid}">
                <v:case case="2" break="TRUE">
                        <div class="thumbnailcontainer_overlay">
                            <p><f:translate key="thumbnail_justforregisteredusers"/></p>
                        </div>
                </v:case>
                ...

No matter what I change, I always get the same error, like shown above. Even when I comment out the responsible Partial, which confuses me a lot! I allready cleared all chaches(in Install Tool), tried other namespaces and doublechecked my switch statement.

Thanks in advance!


Solution

  • If your version of Typo3 is 8.7.19, you probably have a vhs version greater than 2.4.0, so the switch functionality has been moved directly into fluid.

    You should try something like that :

    <f:switch expression="{person.gender}">
      <f:case value="male">Mr.</f:case>
      <f:case value="female">Mrs.</f:case>
      <f:case default="TRUE">Mrs. or Mr.</f:case>
    </f:switch>
    

    More infos : https://fluidtypo3.org/viewhelpers/fluid/master/SwitchViewHelper.html