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!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 15:59:31
Script start
Timing: Jan 18 2025 15:59:31
Module start 'layout'
Timing: Jan 18 2025 15:59:31
Module start 'content'
Timing: Jan 18 2025 15:59:33
Module end 'content'
Timing: Jan 18 2025 15:59:33
Script end

Main resources:

Total runtime1.3271 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 589.1641152.6406
Module start 'layout' 0.00480.0025 741.804739.4766
Module start 'content' 0.00731.3185 781.2813542.0547
Module end 'content' 1.32580.0012 1,323.335912.1250
Script end 1.3270  1,335.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.2202160.0002
Check MTime0.00120.0925160.0001
Mysql Total
Database connection0.00080.063710.0008
Mysqli_queries1.279896.4360570.0225
Looping result0.00050.0386550.0000
Template Total1.296197.720.6480
Template load0.00170.131320.0009
Template processing1.294397.531820.6472
Template load and register function0.00010.008010.0001
states
state_id_array0.00100.077410.0010
state_identifier_array0.00200.147620.0010
Override
Cache load0.00140.1077180.0001
Sytem overhead
Fetch class attribute can translate value0.00050.038620.0003
Fetch class attribute name0.00100.079150.0002
XML
Image XML parsing0.00100.076820.0005
class_abstraction
Instantiating content class attribute0.00000.000860.0000
General
dbfile0.00190.1399230.0001
String conversion0.00000.000440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs