Styling Links for Main Article's Subpage

Author Message

DeAndre Johnson

Wednesday 10 December 2008 5:00:35 pm

I want to be able to style the subpages links individually. The problem I'm having is with:

<h2 class="subpages">
<ul>
{foreach $valid_node.children as $child}
<li>
<a href="{$child.url_alias|ezurl(no)}">{$child.name}</a>
</li>
{/foreach}
</ul>
</h2>

Outputing this:

<h2 class="subpages">
<ul>
<li><a href="/>title</a></li>
<li><a href="/>title</a></li>
<li><a href="/>title</a></li>
<li><a href="/>title</a></li>
</ul>
</h2>

But I would like it to output html like this:

<h2 class="subpages">
<ul>
<li class="page1"> <a href="/>title</a></li>
<li class="page2"><a href="/>title</a></li>
<li class="page3"><a href="/>title</a></li>
<li class="page4"><a href="/>title</a></li>
</ul>
</h2>

How can this be achieved?

I am, because I choose to be!

Daniel Hoppe

Thursday 11 December 2008 3:14:19 am

You can increment a counter within the FOREACH

Arnaud Lafon

Thursday 11 December 2008 4:14:25 am

If you need an "indexed" style :

<h2 class="subpages">
<ul>
{foreach $valid_node.children as $child_index => $child}
<li class="page{$child_index}">
<a href="{$child.url_alias|ezurl(no)}">{$child.name}</a>
</li>
{/foreach}
</ul>
</h2>

You can also use the sequence parameter :

<h2 class="subpages">
<ul>
{foreach $valid_node.children as $child_index => $child sequence array( 'page1', 'page2', 'page3', 'page4' ) as $li_class}
<li class="{$li_class}">
<a href="{$child.url_alias|ezurl(no)}">{$child.name}</a>
</li>
{/foreach}
</ul>
</h2>

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

DeAndre Johnson

Friday 12 December 2008 7:22:41 pm

Thanks Arnaud, that worked perfectly.

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 30 2025 21:33:02
Script start
Timing: Jan 30 2025 21:33:02
Module start 'layout'
Timing: Jan 30 2025 21:33:02
Module start 'content'
Timing: Jan 30 2025 21:33:02
Module end 'content'
Timing: Jan 30 2025 21:33:02
Script end

Main resources:

Total runtime0.0331 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0126 588.2656151.2266
Module start 'layout' 0.01260.0047 739.4922220.7188
Module start 'content' 0.01730.0143 960.21091,001.9609
Module end 'content' 0.03160.0015 1,962.171933.9922
Script end 0.0331  1,996.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00288.3831140.0002
Check MTime0.00113.4122140.0001
Mysql Total
Database connection0.007321.946110.0073
Mysqli_queries0.003410.182530.0011
Looping result0.00000.051110.0000
Template Total0.00113.310.0011
Template load0.00092.579110.0009
Template processing0.00020.676810.0002
Override
Cache load0.00061.790710.0006
General
dbfile0.00113.394980.0001
String conversion0.00000.023840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs