Get first/last link of mulit-leveled menu

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
konsument
Forum Members
Forum Members
Posts: 137
Joined: Thu Oct 26, 2006 9:20 am

Get first/last link of mulit-leveled menu

Post 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!
User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

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

Post 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
Make your community a better place!
konsument
Forum Members
Forum Members
Posts: 137
Joined: Thu Oct 26, 2006 9:20 am

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

Post 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?
Post Reply

Return to “CMSMS Core”