jeudi 26 août 2021

Is there a better way to check if more than two strings exists on Typo3 fluid?

Here is my working not DRY code (using VHS ViewHelper):

<v:condition.string.contains haystack="{pathFile}" needle=".jpg">
      <f:then>JPG ICON</f:then>
      <f:else>
        <v:condition.string.contains haystack="{pathFile}" needle=".svg">
          <f:then>SVG ICON</f:then>
          <f:else>
            <v:condition.string.contains haystack="{pathFile}" needle=".pdf">
              <f:then>PDF ICON</f:then>
              <f:else>SOME OTHER ICON</f:else>
            </v:condition.string.contains>
          </f:else>
        </v:condition.string.contains>
      </f:else>
</v:condition.string.contains>

I used v:iterator.explode as well to get the string I want and compare it, but maybe there is a simpler way using v:condition.string.contains or another aproach

Aucun commentaire:

Enregistrer un commentaire