Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fluid condition with ContainsViewHelper

i use this condition in my fluid template:

<f:if condition="{settings.image.className} == 'lightbox'">
                <f:then>
                    ....do something
                </f:then>

        <f:else>
          <f:if condition="{settings.image.className} !== 'lightbox'">
                <f:then>
                 ....do something else
                </f:then>
         </f:if>
         </f:else>

It works fine but if $settings.image.className" is something like "lightbox container" instead of just "lightbox" it does not work of course. Unfortunately i do not know how write a condtion that checks if $settings.image.className contains "lightbox" or not.

The only instructions i found are here: ViewHelper Reference .However i do not know how to apply that.

like image 680
chicky Avatar asked Jul 14 '15 12:07

chicky


1 Answers

add this to the top of the partial/content Element

{namespace v=FluidTYPO3\Vhs\ViewHelpers}

and change the logic like this

<v:condition.string.contains haystack="{settings.image.className}" needle="lightbox">
   <f:then>
        ....do something
   </f:then>
   <f:else>
        ....do something else
   </f:else>
</v:condition.string.contains>
like image 196
Hans Koch Avatar answered Nov 07 '22 14:11

Hans Koch