We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25803 ☆ A M B ☆
    • 721 Posts
    Hello,

    The HTML/CSS template I'm using has a structure like this:

    <ul class="two_column">
    	<li>
    		<div class="block-text quick">
    			<a href="#">Link A</a>
    		</div>
    	</li>
    	<li class="nomargin">
    		<div class="block-text quick">
    			<a href="#">Link B</a>
    		</div>
    	</li>
    	<li>
    		<div class="block-text quick">
    			<a href="#">Link C</a>
    		</div>
    	</li>
    	<li class="nomargin">
    		<div class="block-text quick">
    			<a href="#">Link D</a>
    		</div>
    	</li>
    	<li class="clear"></li>
    </ul>
    


    So a typical MIGX setup might look like this:

    <ul class="two_column">
    	[[!getImageList?
               &tvname=`quickButtons`
               &tpl=`quickButtonTPL`
               &placeholdersKeyField=`idx`        
            ]]
    	<li class="clear"></li>
    </ul>
    


    Where quickButtonTPL would be:

    <li>
        <div class="block-text quick">
          <a href="[[~[[+quickLink]]]]">[[+quickLinkCopy]]</a>
        </div>
    </li>
    


    But in this case I need every second template to be:

    <li class="nomargin">
        <div class="block-text quick">
          <a href="[[~[[+quickLink]]]]">[[+quickLinkCopy]]</a>
        </div>
    </li>
    


    In the docs we have this:


    Using &tpl=`@FIELD:` you can use any field as the template name to switch template from item to item


    [[!getImageList?
      &tvname=`myMIGXtv`
      &tpl=`@FIELD:tpl`
    ]]
    


    If you have specified a field name "tpl" from the MIGX TV setup, getImageList will use the value of this field for the items's tpl. The value must be exactly what you would put in the &tpl property - a chunk name, @CODE:... @FILE...

    But I gather that this makes the content publisher (or client) have to decide to use on or the other themselves rather just using the second template on every alternate row. Is that correct?

    If so, an approach I've used in the past is to make the template something like this:


    <li [[If?&subject=`[[+idx]]`&operator=`ia`&operand=`2,4,6,8,10,12,14,16,18,20`&then=`class="nomargin`]]>
        <div class="block-text quick">
          <a href="[[~[[+quickLink]]]]">[[+quickLinkCopy]]</a>
        </div>
    </li>
    


    I'm a little concerned about performance.

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

    • discuss.answer
      • 4172
      • 5,888 Posts
      there is &tpl_nN in your case for every second

      &tpl_n2=`odd_tpl`


      or you can use the placeholder
      [[+_alt]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 25803 ☆ A M B ☆
        • 721 Posts
        Perfect. I missed that template command in the docs.