We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi all,

    Is this possible? Here is the theory...

    I have a number of Chunks which are Templates of HTML that I want to render onto a page, the thing is, for each page I want to be able to set which Chunk template should be used based on the value of a TV I set...

    Therefore If I set the TV to be 1 - then I want getResources to display the ChunkTpl1, if I set the TV to be 2 - then I want getResources to display the ChunkTpl2...

    How would one achieve this? I have tried numerous things but cant seem to get my head around using IF’s in getReources...



    Thanks!

    dubbs.
      • 8168
      • 1,118 Posts
      It seems this is possible as just created a solution that worked! Sample code below for those interested...

      [[!getResources? &resources=`[[*id]]` &limit=`1` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` 
      &tvFilters=`showTpl==1` &tpl=`Tpl1`
      &tvFilters=`showTpl==2` &tpl=`Tpl2`
      &tvFilters=`showTpl==3` &tpl=`Tpl3`
      ]]
      



      dubbs smiley
        • 8168
        • 1,118 Posts
        Sorry.... to hasty! that solution above does not work... just renders the last template call regardless of setting of the TV...
          • 8168
          • 1,118 Posts
          Solved it! Dont use getResources - use ifEval! Sample below:

          [[!ifEval? &input=`[[*portfolioItemGalleryImagesNumberOf]]=="1"`
          &contentTrue=`
          <p>Tpl1</p>
          ` 
          &contentFalse=` `]]
          
          [[!ifEval? &input=`[[*portfolioItemGalleryImagesNumberOf]]=="2"`
          &contentTrue=`
          <p>Tpl2</p>
          ` 
          &contentFalse=` `]]
          
          [[!ifEval? &input=`[[*portfolioItemGalleryImagesNumberOf]]=="3"`
          &contentTrue=`
          <p>Tpl3</p>
          ` 
          &contentFalse=` `]]