We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46630
    • 40 Posts
    Probably it's an easy question but I can't figure it out.

    I have 3 column grid layout and I would like to put in the first column the first resource of the modx tree. in the second column I would like to pud the second resource and the place of the third is in the third column.

    So with getResources is quite easy to call the first resource:

     [[!getResources?  
            &parents=`7` 
             &tpl=`klasacia-fp-1-tpl`  
            &limit=`1`  
            &sortdir=`DESC`  
            &includeTVs=`1`  
            &includeContent=`1`   
            &depth=`1`  
            &sortby=`menuindex`  
            ]]  


    But how about the second and the third. I don't want to include and change frequently their ID's in getResource code. It has to be automatic, so the user could rearange the resources in the tree.

    Thank you for your help.

    This question has been answered by Bruno17. See the first response.

      • 30912
      • 463 Posts
      You can do this with nth tpls. (not tested just off the top of my head)

      [[!getResources? 
             &parents=`7`
              &tpl=`klasacia-fp-1-tpl` 
      &tpl_2=`klasacia-fp-2-tpl`
      &tpl_3=`klasacia-fp-3-tpl`
             &limit=`3` 
             &sortdir=`DESC` 
             &includeTVs=`1` 
             &includeContent=`1`  
             &depth=`1` 
             &sortby=`menuindex` 
             ]]


      then haave your tpls something like this:

      klasacia-fp-1-tpl
      <div class="first-col">
      [[[+placeholders]]
      </div>
      


      klasacia-fp-2-tpl
      <div class="second-col">
      [[[+placeholders]]
      </div>
      


      klasacia-fp-3-tpl
      <div class="third-col">
      [[[+placeholders]]
      </div>
      


      and wrap it all inside your row

      <div class="content-row">
      [[!getResources? 
             &parents=`7`
              &tpl=`klasacia-fp-1-tpl` 
      &tpl_2=`klasacia-fp-2-tpl`
      &tpl_3=`klasacia-fp-3-tpl`
             &limit=`3` 
             &sortdir=`DESC` 
             &includeTVs=`1` 
             &includeContent=`1`  
             &depth=`1` 
             &sortby=`menuindex` 
             ]]
      </div>
      


      This will output 3 of the resources in each column, this is all assuming you have your columns set up in that way.

      The other way you could do it is in each column have a getResources call and in the second column have &offset=`1` and the third column &offset=`2` but you will be processing three snippet calls here instead of the one.
      • discuss.answer
        • 4172
        • 5,888 Posts
        &offset=`2`
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 46630
          • 40 Posts
          Thanks, Bruno17! Nice and short.