We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29597 ☆ A M B ☆
    • 350 Posts
    Hello I am working on my template project for MODX Revo: Flexibility.
    https://github.com/DESIGNfromWITHIN/Flexibility

    I am creating a template with some default TV's where you can change the layout of the page.

    With TV: Sub-content boxes you can choose if you want a sub content box below the main content. and how many boxes of these you want.
    These content boxes will the be added to the template to be used in a responsive Inuit CSS grid.

    My current code structure is this:
    [[*content]]
    [[If?
    &subject=`[[*page_boxes]]`
    &operator=`EQ`
    &operand=`2`
    &then=`
    <div class="grids">
    	<div class="grid-6">
    		[[*page_box_01]]
    	</div>
    	<div class="grid-6">
    		[[*page_box_02]]
    	</div>
    </div>
    `]]
    [[If?
    &subject=`[[*page_boxes]]`
    &operator=`EQ`
    &operand=`3`
    &then=`
    <div class="grids">
    	<div class="grid-4">
    		[[*page_box_01]]
    	</div>
    	<div class="grid-4">
    		[[*page_box_02]]
    	</div>
    	<div class="grid-4">
    		[[*page_box_03]]
    	</div>
    </div>
    `]]
    [[If?
    &subject=`[[*page_boxes]]`
    &operator=`EQ`
    &operand=`4`
    &then=`
    <div class="grids">
    	<div class="grid-3">
    		[[*page_box_01]]
    	</div>
    	<div class="grid-3">
    		[[*page_box_02]]
    	</div>
    	<div class="grid-3">
    		[[*page_box_03]]
    	</div>
    	<div class="grid-3">
    		[[*page_box_04]]
    	</div>
    </div>
    `]]


    As you can see this is using 3 cached IF statements and I am sure this could be improved... Does anybody have an idea on how to make this better?

    I will also add a IF type statement to add or leave out a Orbit slider and a sidebar.
    I would love some suggestions on how to do this without adding a lot of templates.

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

      MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
      DESIGNfromWITHIN, MPThemes and Any Screen Size
      Follow me on Twitter | Read my blog | My code on GitHub
    • discuss.answer
      • 33976 ☆ A M B ☆
      • 571 Posts
      Hey,

      You might want to give a try to Switch snippet, it might better fit your needs
        • 29597 ☆ A M B ☆
        • 350 Posts
        Looks like what I need but I cant get the basics from the explanation... could you help me with a example?
          MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
          DESIGNfromWITHIN, MPThemes and Any Screen Size
          Follow me on Twitter | Read my blog | My code on GitHub
          • 29597 ☆ A M B ☆
          • 350 Posts
          Oh I got it:
          [[switch?
          &get=`[[*page_boxes]]`
          &c1=`2`
          &do1=`<div class="grids">
          	<div class="grid-6">
          		[[*page_box_01]]
          	</div>
          	<div class="grid-6">
          		[[*page_box_02]]
          	</div>
          </div>`
          &c2=`3`
          &do2=`<div class="grids">
          	<div class="grid-4">
          		[[*page_box_01]]
          	</div>
          	<div class="grid-4">
          		[[*page_box_02]]
          	</div>
          	<div class="grid-4">
          		[[*page_box_03]]
          	</div>
          </div>`
          &c3=`4`
          &do3=`<div class="grids">
          	<div class="grid-3">
          		[[*page_box_01]]
          	</div>
          	<div class="grid-3">
          		[[*page_box_02]]
          	</div>
          	<div class="grid-3">
          		[[*page_box_03]]
          	</div>
          	<div class="grid-3">
          		[[*page_box_04]]
          	</div>
          </div>`
          &default=``]]
            MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
            DESIGNfromWITHIN, MPThemes and Any Screen Size
            Follow me on Twitter | Read my blog | My code on GitHub