On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Modx => 2.7
    CSS => Skeleton
    getResources => 1.6.1
    getResourcesTpl chunk => <div class="three columns">code...</div>

    Hi,
    Here is the structure of my page (see the attachment)

    <div class="container">
    <!-- First Row -->
    <div class="row">
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    </div> <!-- end Row -->

    <!--Second Row -->
    <div class="row">
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    </div> <!-- end Row -->

    <!-- N.. Row -->
    <div class="row">
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    <div class="three columns">code...</div>
    </div> <!-- end Row -->
    </div> <!-- end Container -->

    I'm trying with getResources to generate this structure. That is to say a row to all 4 children. I could not do it.

    I also tried with the snippet getResourcesColumns from SepiaRiver. I followed his insruction but without success.
    Source : https://tinyurl.com/yc7j8nfd

    My question, is it possible in a simple way with getResources to generate this structure.

    Thank you
    • Mark Hamstra Reply #2, 5 months ago
      You can use the modulus for that, or &tpl_nN.

      For the modulus, you'd put something like this into your chunk:

      [[+idx:mod=`4`:eq=`0`:then=`</div><div class="row">`:else=``]]
      <div class="three columns">code...</div>
      


      With &tpl_nN, you'd add this to your getResources call:

      &tpl_n4=`getResourceChunk4th`


      and in the chunk getResourceChunk4th you'd close and open your row like the previous example.

      Wrap your getResources in the "outer" row, and it should be pretty fault-proof.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.