Forums / Setup & design / Add "firstli and lastli" classes to list

Add "firstli and lastli" classes to list

Author Message

DeAndre Johnson

Saturday 26 September 2009 10:51:33 am

Hello, I would like to know how to add firstli and lastli classes to list items for css styling. Like so

<ul>
<li class="firstli'></li>
<li></li>
<li class="lastli'></li>
</ul>

Thanks for any help

I am, because I choose to be!

Steven E. Bailey

Sunday 27 September 2009 12:29:12 am

This is how I do it - something like this:

<ul>
{foreach $item_list as $index => $item}
	<li class="{cond(eq($index,0),'firstli',eq($index,dec($item_list_count)),'lastli','normalli')}">This is {$index} for {$item}</li>
{/foreach}
</ul>

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

DeAndre Johnson

Sunday 27 September 2009 9:02:12 pm

Thanks. That worked as needed.

I am, because I choose to be!