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

    I'm trying to change the template chunk used by getResources every 3 iterations, i.e. every third result uses the alternative chunk.

    My call is as follows:

    	      [[!getResources?
    
    		&tpl=`productList.item`
      		&tpl_3=`productList.itemLast` 
    		&hideContainers=`0`
    		&pageVarKey=`page`
    		&parents=`[[*id]]`
    		&includeTVs=`1`
      		&processTVs=`1` 
    		&includeContent=`1`
    	        &limit=`10`
    	        &pageVarKey=`page`
    		&sortby=`{"menuindex":"ASC"}`
    	      ]]


    But this appears to fail after the first iteration, any ideas?

    Cheers,

    Steve
      • 36502 ☆ A M B ☆
      • 491 Posts
      mm, I'm afraid you can only set a different template for odd resources, otherwise you have to specify each multiple of 3...I don't know how many resources you have, in a similar situation I did this way:

      [[!getResources?
       &tpl=`productList.item`
      &tpl_3=`productList.itemLast` 
      &tpl_6=`productList.itemLast`
      &tpl_9=`productList.itemLast`
      &tpl_12=`productList.itemLast`
      ...]]
      
        TilliLab | MODX Ambassador
        website
        • 6437
        • 157 Posts
        Thanks tillilab.

        I think I've just thought of a more effective way using conditionals based on the idx property, but this will take a little more thinking about.

        Thanks again for your help, this solution will work in the interim.

        Cheers,

        Steve
          • 36502 ☆ A M B ☆
          • 491 Posts
          well, may be there is a more effective way, as you say this is ok ad interim smiley

            TilliLab | MODX Ambassador
            website
            • 22303 MODX Staff
            • 10,725 Posts
            I was experimenting with adding a factorial function that would allow tpl_x3 (for every multiple of 3) or tpl_x6 (for every multiple of 6). Feel free to add a formal feature request for this.
              • 6437
              • 157 Posts
              Will do.

              Would I be right in thinking that it would be possible with conditional idx?

              Steve