Hi guys!
while developing a my own custom theme for drupal 6.6 I got stuck, because I don't know how to get the parent of the current node and its submenu to render it in a navigation vertical left sidebar.
I explain the problem: I am using the primary links menu to organize the content of my website, and I am displaying it entirely and correctly in a horizontal navigation bar. What I need now is a vertical navigation bar in the left sidebar of the website, and it should display only a submenu of it:
my primary links menu structure is:
Home
History
--history1
--history2
----history21
----history22
--history3
About us
--overview
the following three cases are the use cases:
1) when I go in the history1 node then in the sidebar they have to be:
-----------
Hystory (i.e. the name of the current node's parent)
-----------
history1
history2 (i.e. the name and the link of the current node)
history3
2) when I go in the history2 node then in the sidebar they have to be:
---------
history2
---------
history21
history22
3) when I go in the history21 node then in the sidebar they have to be:
---------
history2
---------
history21
history22
So, my question is: how can I do that? :)
Best regards
Michele
Comments
it is simple to build !!!!
Hi Michele,
I may help you on this, but i need to know what is your solution architecture?
are you using taxonomy or creating a simple page and assigning path of page to a menu-item?
Best,
Drupal Rocking
simple pages
hello, thanks for your answer!
I am creating simple pages and adding their paths to a menu: the primary links menu to be more precise.
I am not using taxonomy.
Best regards
Michele
Here are the few options
Hi Michele,
option1:
Why don't you use the book module.It provides the same feature you are looking for.
It provides the capability to have navigation,"Book navigation" block with two different option.(Show block on all pages,
Show block only on book pages).
here is the implementation using same idea.
http://luxurycouncil.com/ (about menu)
option2:
Menu Trails module may help you since you are not using the taxonomy - http://drupal.org/project/menu_block_split
Let me know any of the option will help you or not,i have few other options too to implement this.
Best,
Drupal Rocking
I got the book
Hello, thanks for your answer!
I solved that by myself by using some crafted functions who query the menu table in the drupal db, using the node path as key: they works good for me, and due the deadline I think I'll keep them.
Anyway I thank you again for telling me about the menu_block_module: I think it will be worth looking at its code and hack on it. :)
Best regards
Michele
Please Share
Hello, can you please share your solution? I'm trying to do the same thing. Thanks.
second this..
I am looking for this as well. I can't believe that this isn't an easier thing to do already.
after poring over the API
after poring over the API for hours, i think i've got a custom bit of code (read: hack) in place to pull this off for Drupal 6.
to reiterate, my scenario is that i have one comprehensive site menu as my Primary Links. i want to display the entire menu via Nice Menus at the top of my theme, but show context-specific "submenus" (starting one level down from the primary links, and showing the entire tree underneath) in blocks.
the hack is based on a modified version of Drupal's menu_navigation_links function, that stops short and returns the multi-level menu tree array, rather than continuing on to return the single level links array. we can then pass the returned tree through menu_tree_output to get the markup.
the second argument of the function specifies that we want to start one level below the primary links.
(hat tip to http://www.freesoftwaremagazine.com/books/drupal_tricks/tertiary_menu for pointing me in the right direction.)
i'd love to hear how this compares to your solution, Michele, or if anyone else can point out something simpler that i'm missing!
Demonstration Site
Can you share the site url, where you have implemented this.
This will help other community member to try the demonstration too.
sorry, the site's not public
sorry, the site's not public yet. but as far as what you'll see rendered to the page, it's pretty simple to describe:
1) the entire site menu is contained in the Primary Links which are printed at the top of the page (i happen to be using nice_menus to display those in a manageable way, but that's beside the point)
2) the sidebar includes a block that only shows the "submenu" of the "section" you're in (in my case, that means "tier 2" links and below in the menu tree)
note that this is subtly different than the original use cases listed above. in my case, whether i'm at 'History', 'history2', or 'history22', i will see the following in my "submenu" in the sidebar:
History
--history1
--history2
----history21
----history22
--history3
here's the code, cleaned up a bit. first, in template.php:
then, in my sidebar "submenu" block:
Thanks
Thanks arh1, that code is perfectly reusable and works nicely for a project I'm working on.
No need for a “hack”
http://drupal.org/project/menu_block does what you are wanting.
- John (JohnAlbin)
thanks, JohnAlbin. i use the
thanks, JohnAlbin.
i use the word "hack" here somewhat loosely -- my code above doesn't feel bad in that it's easy enough to maintain at the theme level. personally, i always prefer that to another contrib module, where i'm less confident i'll be able to maintain it should the developers go away, lose interest, etc.
that said, menu_block looks pretty great, and like you, i'm shocked this module didn't exist before. and clearly this module is maintained by a reputable and invested developer :) thanks for pointing it out.
Local Menu Module
To me it sounds like you might like the Local Menu Module. When you go to the link the explanation of the module is a little weird, but I think it is the solution you are looking for.
http://drupal.org/project/local_menu
good to know! that does
good to know! that does indeed look like a good match. for my part, i prefer to handle this type of thing w/ my own code at the theme level if possible, but thanks for the pointer.
This is exactly what I was looking for
Thanks!
www.lullabyte.com
local_menu vs. menu_block
I've put a comparison of the two modules on http://drupal.org/project/menu_block
- John (JohnAlbin)