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.