Page 1 of 1

Get first/last link of mulit-leveled menu

Posted: Sun Jan 10, 2010 7:17 pm
by konsument
Hi Folks,

as the title says - I need to get the first and last link of each rendered level in a menu.

Example:

-> Parent 1 (class="first")
---> Child 1  (class="first")
---> Child 2 
-----> Child Child 1 (class="first")
-----> Child Child 2
-----> Child Child 3
-----> Child Child 4 (class="last")
---> Child 3
---> Child 4 (class="last")
-> Parent 2
-> Parent 3
-> Parent 4 (class="last")

I allready tried it with

Code: Select all

{if $smarty.foreach.submenu.last}
but this gives me just the last/first link for all links in menu:

-> Parent 1 (class="first")
---> Child 1
---> Child 2 
-----> Child Child 1
-----> Child Child 2
-----> Child Child 3
-----> Child Child 4
---> Child 3
---> Child 4
-> Parent 2
-> Parent 3
-> Parent 4 (class="last")

I also asked in IRC yesterday. Sb gave me the hint to work with

Code: Select all

{if $node->depth > $node->prevdepth}
- but after hours of searching and trying i didnt found a solution  :(

Maybe theres someone out there how can help me with this issue? That would be great!

Re: Get first/last link of mulit-leveled menu

Posted: Sun Jan 10, 2010 8:44 pm
by M@rtijn
I've been experiencing the same problem, when I trying to make a custom menu.

I've solved it with:

Code: Select all

$node->index > 1 and $node->haschildren == false
Gives you the first of every child

and

Code: Select all

$node->depth < $node->prevdepth
Which gives you the last of evert pair of children

Hope this provides any guidance

Re: Get first/last link of mulit-leveled menu

Posted: Sun Jan 10, 2010 9:20 pm
by konsument
Thanks for your advice  :)

But it seems like this doesnt really helps me solving my problem.

Code: Select all

$node->index > 1 and $node->haschildren == false
This would only get all level 2 links without any children.

But perhaps I get you wrong?

Where did you insered the code in your template?