Page 1 of 1
[Solved] How to add css class to every second news article?
Posted: Tue Jul 05, 2011 8:01 pm
by urheat
I have to have different CSS properties for every second news article. How this could be done? I would like to get following source code:
Code: Select all
<div class="NewsSummary Left">
...
</div>
<div class="NewsSummary Right">
...
</div>
<div class="NewsSummary Left">
...
</div>
and so on...
Re: How to add css class to every second news article?
Posted: Tue Jul 05, 2011 8:09 pm
by Jos
Re: How to add css class to every second news article?
Posted: Wed Jul 06, 2011 9:37 am
by urheat
Thanks for the tip! But if you or someone else has already solution (maybe example code?) I would save a lot of time 'cause I'm not pro with smarty coding...
Re: How to add css class to every second news article?
Posted: Wed Jul 06, 2011 9:45 am
by Jos
Code: Select all
{foreach from=$items item=entry name=newsentry}
<div class="NewsSummary {if $smarty.foreach.newsentry.index % 2 == 0}Left{else}Right{/if}">
</div>
{/foreach}
Don't forget to add the name=newsentry to the foreach statement.
Re: How to add css class to every second news article?
Posted: Wed Jul 06, 2011 10:45 am
by RonnyK
I often use....
Code: Select all
{foreach from=$items item=entry}
{cycle values='row1,row2' assign='currow'}
<div class="NewsSummary {$currow}">
Ronny
Re: How to add css class to every second news article?
Posted: Wed Jul 06, 2011 10:46 am
by Jos
ah yes, cycle is also a nice function for this... forgot how simple things can be sometimes

Re: How to add css class to every second news article?
Posted: Fri Aug 19, 2011 7:06 pm
by micahgodbolt
Jos wrote:ah yes, cycle is also a nice function for this... forgot how simple things can be sometimes

Where is the plus 1 button

Re: How to add css class to every second news article?
Posted: Fri Aug 19, 2011 7:44 pm
by Wishbone
pcfcopies wrote:Where is the plus 1 button


Re: [Solved] How to add css class to every second news artic
Posted: Fri Aug 19, 2011 7:50 pm
by uniqu3
@Wishbone LOL can't click