Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
lou cat
3rd level navigation
May 28, 2012 9:41 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Hi!

I am getting crazy trying to implement a 3rd level navigation in my velocity side navigation template.

It should work like this:

- root
-- child
-- child
-- child
-- child_with_children
---grandchild
---grandchild
---grandchild
-- child

Usually the root is marked as "selected" if any of its children is selected, but with the 3rd level this doesn't happen, so if a grandchild is selected, root results selected but its parent (child_with_children) is not.
Why? In this other thread (http://www.liferay.com/community/forums/-/message_boards/message/8018380) they talk about bugs... is there a solution to implement this?

I'd like to have the whole grandchild menu (so the 3 grandchildren) visibile only if their parent (child_with_children) is selected, or if any of the grandchildren is selected.

Do you have any suggestion?

Thanks!!!
Amit Doshi
RE: 3rd level navigation
May 28, 2012 12:15 PM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 544

Join Date: December 29, 2010

Recent Posts

Please check below link :-

http://www.liferay.com/community/forums/-/message_boards/view_message/5679151

Regards,
Amit Doshi
lou cat
RE: 3rd level navigation
May 29, 2012 1:22 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Hi Amit,

Thanks but you linked the same thread I was mentioning... I can't see any solution in that one, am I missing something? emoticon
jaid shaik
RE: 3rd level navigation
May 29, 2012 2:53 AM
Answer

jaid shaik

Rank: Regular Member

Posts: 170

Join Date: October 7, 2010

Recent Posts

Hi lou,

Check the configuration right side of navigation portlet,

Display style:custom

Root layout level: 0 or 1 or 2 check depend on your child page menu..

The above configuration is worked for me at 3rd level of navigation portlet.
lou cat
RE: 3rd level navigation
May 29, 2012 2:57 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

I'm not using a navigation portlet, I need my own implementation so I'm editing a velocity template...
lou cat
RE: 3rd level navigation
May 30, 2012 3:15 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Ok at least it's possible... I now got a super messy code full of flags and loops, but it works.
I just feel (and I've seen I'm not the only one) this behaviour is a bit strange and I was wondering if it's going to remain like this also in 6.1 and following versions...
I would prefer getting a "selected" status for the parent page of a selected child (whatever level is considered), or at least having an intermediate status.
lutz Bremen
RE: 3rd level navigation
August 23, 2012 3:44 AM
Answer

lutz Bremen

Rank: Expert

Posts: 296

Join Date: October 20, 2011

Recent Posts

could ushre ur code?
lou cat
RE: 3rd level navigation
August 23, 2012 3:58 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

Well, I'm afraid it's really messy, and it's more complicated than before, but here it is.
Probably not all the flags are needed and there is a simpler way to code this.

It is a side navigation menu with some checks on the page names as I needed short names in the breadcrumb but not in the side menu, I tried to cut that part not to confuse you, don't worry about that.
Attachments: side_navigation.vm (7.4k)
lutz Bremen
RE: 3rd level navigation
August 23, 2012 11:49 PM
Answer

lutz Bremen

Rank: Expert

Posts: 296

Join Date: October 20, 2011

Recent Posts

ok this doesnt help ^^ but i solved it with the help of another code.^^
Rupesh Chotai
RE: 3rd level navigation
February 8, 2013 8:57 AM
Answer

Rupesh Chotai

Rank: Regular Member

Posts: 163

Join Date: March 23, 2011

Recent Posts

Hi Bremen,
Can you please share your solution, we also have similar kind of requirement?

Thanks in advance.
Anonymous
RE: 3rd level navigation
February 8, 2013 9:20 AM
Answer

Anonymous

Checkout this velocity macro that one of my co-workers worked on.

https://github.com/ryanschuhler/liferay-portal/blob/e184230ed76459397ccd310095dd32dea8fa45a2/portal-web/docroot/html/themes/_unstyled/templates/init.vm#L432

navigation.vm
https://github.com/ryanschuhler/liferay-portal/blob/e184230ed76459397ccd310095dd32dea8fa45a2/portal-web/docroot/html/themes/classic/_diffs/templates/navigation.vm
Ryan Schuhler
RE: 3rd level navigation
February 8, 2013 9:55 AM
Answer

Ryan Schuhler

LIFERAY STAFF

Rank: Junior Member

Posts: 76

Join Date: July 5, 2012

Recent Posts

A simple solution to this is to use .isChildSelected() to set the child_with_children to selected when the grandchild is selected. Attached on line 35 is when I have used it.
Attachments: navigation.vm (1.8k)
Jennifer Carr
RE: 3rd level navigation
April 12, 2013 12:12 PM
Answer

Jennifer Carr

Rank: New Member

Posts: 6

Join Date: July 26, 2012

Recent Posts

Ryan Schuhler:
A simple solution to this is to use .isChildSelected() to set the child_with_children to selected when the grandchild is selected. Attached on line 35 is when I have used it.


This is great and exactly what I was looking for too!

I was wondering how you would modify it so that only the selected items showed their children while the others with children didn't?

Actually I am looking for that as well as going down 4 levels deep instead of 3.

Thanks, Jenn
Ryan Schuhler
RE: 3rd level navigation
April 12, 2013 2:58 PM
Answer

Ryan Schuhler

LIFERAY STAFF

Rank: Junior Member

Posts: 76

Join Date: July 5, 2012

Recent Posts

Yes, both of those are possible, for the 4th level just repeat the logic of the above levels. You can add a $nav_item.isSelected to the if statement with $hasChildren to display only the children of selected pages. I attached a changed file. Hopefully it helps, test it out.
Attachments: possibleNavigation.vm (2.7k)
gordon daniels
RE: 3rd level navigation
April 13, 2013 7:17 AM
Answer

gordon daniels

Rank: Liferay Master

Posts: 670

Join Date: August 23, 2008

Recent Posts

Jennifer: I know you are using Ryan's solution. I have used his in the past as well. But you might want to check Bradley Wood's latest blog. He has included code for doing 3rd level nav. Both navigation.vm and custom.css.
Jennifer Carr
RE: 3rd level navigation
September 18, 2013 9:02 AM
Answer

Jennifer Carr

Rank: New Member

Posts: 6

Join Date: July 26, 2012

Recent Posts

Ryan Schuhler:
Yes, both of those are possible, for the 4th level just repeat the logic of the above levels. You can add a $nav_item.isSelected to the if statement with $hasChildren to display only the children of selected pages. I attached a changed file. Hopefully it helps, test it out.



Ryan,

This has helped us a lot so first I want to say thank you!

I was wondering what you'd recommend to modify this to display just the ancestors and the children relative to the page? Sort of like breadcrumbs but with the addition of the page's children (grand children not necessary).
Ryan Schuhler
RE: 3rd level navigation
September 18, 2013 12:18 PM
Answer

Ryan Schuhler

LIFERAY STAFF

Rank: Junior Member

Posts: 76

Join Date: July 5, 2012

Recent Posts

All you need to do is wrap all of the content inside your loop to check if the nav_item is selected, this will make it only print out the given pages ancestors, it would look something like:
1
2#foreach ($nav_item in $nav_items)
3    #if ($nav_item.isSelected())
4        //print out nav_item and children
5    #end
6#end


Hope it helps!