Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
lou cat
3rd level navigation
28. Mai 2012 09:41
Antwort

lou cat

Rang: Regular Member

Nachrichten: 196

Eintrittsdatum: 26. Januar 2012

Neue Beiträge

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
28. Mai 2012 12:15
Antwort

Amit Doshi

Rang: Liferay Master

Nachrichten: 549

Eintrittsdatum: 29. Dezember 2010

Neue Beiträge

Please check below link :-

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

Regards,
Amit Doshi
lou cat
RE: 3rd level navigation
29. Mai 2012 01:22
Antwort

lou cat

Rang: Regular Member

Nachrichten: 196

Eintrittsdatum: 26. Januar 2012

Neue Beiträge

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
29. Mai 2012 02:53
Antwort

jaid shaik

Rang: Regular Member

Nachrichten: 170

Eintrittsdatum: 7. Oktober 2010

Neue Beiträge

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
29. Mai 2012 02:57
Antwort

lou cat

Rang: Regular Member

Nachrichten: 196

Eintrittsdatum: 26. Januar 2012

Neue Beiträge

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
30. Mai 2012 03:15
Antwort

lou cat

Rang: Regular Member

Nachrichten: 196

Eintrittsdatum: 26. Januar 2012

Neue Beiträge

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
23. August 2012 03:44
Antwort

lutz Bremen

Rang: Expert

Nachrichten: 291

Eintrittsdatum: 20. Oktober 2011

Neue Beiträge

could ushre ur code?
lou cat
RE: 3rd level navigation
23. August 2012 03:58
Antwort

lou cat

Rang: Regular Member

Nachrichten: 196

Eintrittsdatum: 26. Januar 2012

Neue Beiträge

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.
Anhänge: side_navigation.vm (7,4k)
lutz Bremen
RE: 3rd level navigation
23. August 2012 23:49
Antwort

lutz Bremen

Rang: Expert

Nachrichten: 291

Eintrittsdatum: 20. Oktober 2011

Neue Beiträge

ok this doesnt help ^^ but i solved it with the help of another code.^^
Rupesh Chotai
RE: 3rd level navigation
8. Februar 2013 08:57
Antwort

Rupesh Chotai

Rang: Regular Member

Nachrichten: 163

Eintrittsdatum: 23. März 2011

Neue Beiträge

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

Thanks in advance.
Anonym
RE: 3rd level navigation
8. Februar 2013 09:20
Antwort

Anonym

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
8. Februar 2013 09:55
Antwort

Ryan Schuhler

LIFERAY STAFF

Rang: Junior Member

Nachrichten: 77

Eintrittsdatum: 5. Juli 2012

Neue Beiträge

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.
Anhänge: navigation.vm (1,8k)
Jennifer Carr
RE: 3rd level navigation
12. April 2013 12:12
Antwort

Jennifer Carr

Rang: New Member

Nachrichten: 6

Eintrittsdatum: 26. Juli 2012

Neue Beiträge

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
12. April 2013 14:58
Antwort

Ryan Schuhler

LIFERAY STAFF

Rang: Junior Member

Nachrichten: 77

Eintrittsdatum: 5. Juli 2012

Neue Beiträge

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.
Anhänge: possibleNavigation.vm (2,7k)
gordon daniels
RE: 3rd level navigation
13. April 2013 07:17
Antwort

gordon daniels

Rang: Liferay Master

Nachrichten: 735

Eintrittsdatum: 23. August 2008

Neue Beiträge

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
18. September 2013 09:02
Antwort

Jennifer Carr

Rang: New Member

Nachrichten: 6

Eintrittsdatum: 26. Juli 2012

Neue Beiträge

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
18. September 2013 12:18
Antwort

Ryan Schuhler

LIFERAY STAFF

Rang: Junior Member

Nachrichten: 77

Eintrittsdatum: 5. Juli 2012

Neue Beiträge

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!