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

    I'm having a nasty issue with getResources that I hope someone can help me address. I'm using it to generate Bootstrap rows. Each row has 2 columns, so the general output form is:
       <div class="row">
          <div class="col-xs-6">
             [[resource goes here]]
          </div>
          <div class="col-xs-6">
             [[next resource goes here]]
          </div>
       </div>
    


    So if there are n elements returned by getResources, there will be n/2 rows, each with 2 columns (the last row will have just one column if there's an odd number of resources).

    To achieve this, I've used getResources this way:
       <div class="row">  <!-- first row -->
       [[!getResources? &parents=`[[*id]]` 
             &limit=`0`
    	 &tpl=`myTpl`
    	 &tpl_n3=`n3Tpl`
             &includeTVs=`1` 
    	 &processTVs=`1`
    	 &includeContent=`1`
    	 &sortby=`menuindex`
    	 &sortdir=`asc`
    	 &depth=`1` ]]
        </div>  <!-- last row -->
    


    myTpl just has <div class="col-xs-6"> [[resource]] </div> in it. n3Tpl has this:
       </div>   <!-- end of current row div -->
       <div class="row">  <!-- start of next row div -->
       [[$myTpl? &idx=`[[+idx]]` ]]   <!-- using the idx= trick to prevent caching issues -->
    


    My problem is that when there are 5 resources returned by getResources, it applies n3Tpl to the third resource, which is correct, but not to the 5th--the last resource always is generated using myTpl. I really need it to generate using n3Tpl. I have no idea why it's using myTpl. I've tried setting &tplLast=``, with no effect.

    Am I doing something wrong? Help would be so greatly appreciated!

    Thank you SO much in advance! [ed. note: pltarr last edited this post 9 years, 3 months ago.]
      • 47690
      • 22 Posts
      You always figure it out after you hit the "post" button... smiley

      In case anyone else runs into this, the solution to this particular issue was to specify &tplFirst=`myTpl` and use &tplOdd=`n3Tpl` instead of &tpl_n3.

      I think I'm still missing something here, though, because this solution wouldn't work if I had 3 columns per row instead of two. If someone can help me see what I'm missing, I'd greatly appreciate it!