Monday 07 August 2006 10:27:02 am
Hello, I have an array of arrays for the purpose of generating the menu of my site. I'd like to add 'class="current" to all <li> that are in the path of the current page. For example, if the actual path is: http://mysite/company/about_us/carlos the menu should look like this:
<ul>
<li><a href="foo">foo</a></li>
<li class="current"><a href="/company">company</a>
<ul>
<li class="current"><a href="/company/about_us">about us</a>
<ul>
<li><a href="/company/about_us/someone">someone</a></li>
<li class="current"><a href="/company/about_us/carlos">carlos/</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="/company/bar">bar</a></li>
</ul>
In the array of the menu, every item looks like this:
{def $item = hash(
"text_to_show", "foo bar",
"nodeID", 666
)
}
I'd like to process the menu item like this:
{if $node.url_alias|contains($item.text_to_show|SOME_OPERATOR_HERE)}
<li class="current"><a href={fetch('content','node',hash('node_id',$item.nodeID)).url_alias|ezurl}>{$item.text_to_show</a></li>
{else}
<li><a href={fetch('content','node',hash('node_id',$item.nodeID)).url_alias|ezurl}>{$item.text_to_show</a></li>
{/if}
Any idea about the SOME_OPERATOR_HERE? thanks
|