Page 1 of 1

[TIP] cms generated items > last item styled differently

Posted: Sun Oct 18, 2009 10:33 am
by essexboyracer
I was using the excellent gallery module but wanted the output to style the last item differently, i.e. each thumb had a right margin of 5px, but I didnt want the last thumb in the row to have that, otherwise it would drop that thum to the next row and so on.

In your gallery template, insert the following:

Code: Select all

{foreach from=$images item=image name=foo}
  {if $smarty.foreach.foo.index % 4 == 3}
	<div class="img" style="margin-right: 0;">
  {else}
	<div class="img">
  {/if}
It will allow you to style the fourth image with no right margin. Found on http://www.smarty.net/manual/en/languag ... oreach.php

Re: [TIP] cms generated items > last item styled differently

Posted: Mon Nov 02, 2009 9:40 pm
by applejack
You would be better to use last i.e.

Code: Select all

{foreach from=$images item=image name=foo}
  {if $smarty.foreach.foo.last}
	<div class="img" style="margin-right: 0;">
  {else}
	<div class="img">
  {/if}
{/foreach}