We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54732
    • 20 Posts
    Hi, I'm trying insert a bootstrap v4 column for every entry in a MIGX variable into a page. However, I need to have html inserted only on the every 3rd entry to create a new row and set of columns. This is what I have, but will not allow me to create multiple rows of 3 columns each. Is there a way to do this? Thanks!!!

    [[+_first:is=`0`:then=`<div class="row">`:else=``]]   <!-- Also need inserted every 4th -->
    	<div class="col text-center">
            <img src="[[++assets_url]]img/flame.png" class="" />
            <h2>[[+client_name]]</h2>
            <hr>
            <h3>[[+client_story]]</h3>
        </div>
    [[+_last:is=`1`:then=`<div>`:else=``]]  <!-- Also need inserted every 3rd -->

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

    [ed. note: ceramicmonster last edited this post 5 years, 4 months ago.]
    • discuss.answer
      • 44064
      • 185 Posts
      That's good,
      [[+_first:is=`0`:then=`<div class="row">`:else=``]] 
      [[+_last:is=`1`:then=`<div>`:else=``]] 
      

      PLUS between first and last conditions:
      [[+idx:mod=`3`:is=`0`:then=`</div>`]] <!--you should close previous block-->

      and after
      [[+idx:mod=`4`:is=`0`:then=`<div class="row">`]] <!--you should open new block-->
      <div class="col text-center">...</div>
        Anton Tarasov
        MODX Developer

        Email: [email protected]
        Web: antontarasov.com
        • 54732
        • 20 Posts
        Quote from: himurovi4 at Nov 14, 2018, 10:29 AM
        That's good,
        [[+_first:is=`0`:then=`<div class="row">`:else=``]] 
        [[+_last:is=`1`:then=`<div>`:else=``]] 
        

        PLUS between first and last conditions:
        [[+idx:mod=`3`:is=`0`:then=`</div>`]] <!--you should close previous block-->

        and after
        [[+idx:mod=`4`:is=`0`:then=`<div class="row">`]] <!--you should open new block-->
        <div class="col text-center">...</div>
        </div></div>

        I'm a bit confused, sorry. Can you show me the complete code? Thank you!
          • 54732
          • 20 Posts
          Quote from: ceramicmonster at Nov 14, 2018, 07:07 PM
          Quote from: himurovi4 at Nov 14, 2018, 10:29 AM
          That's good,
          [[+_first:is=`0`:then=`<div class="row">`:else=``]] 
          [[+_last:is=`1`:then=`<div>`:else=``]] 
          

          PLUS between first and last conditions:
          [[+idx:mod=`3`:is=`0`:then=`</div>`]] <!--you should close previous block-->

          and after
          [[+idx:mod=`4`:is=`0`:then=`<div class="row">`]] <!--you should open new block-->
          <div class="col text-center">...</div>
          </div></div>

          I'm a bit confused, sorry. Can you show me the complete code? Thank you!
          Nevermind, I got it. THANKS!