By wrburgess on
So far, in D6.x, I can get the Primary Links to run horizontally across the top of my template and the Secondary Links to run vertically in the left side bar.
Is there a way to produce both the second-level and third-level links in the Secondary Links block? Right now, I can only get the second-level links to persist.
I don't care about drop downs or fancy styling at this point. I just want both second-level and third-level links to be exposed and driven by the Primary Links.
Any assistance is appreciated.
Comments
try this
go to /admin/build/menu/settings and set the secondary links to be the same menu you use for primary links. You don't use a separate menu for secondary links anymore.
That way the (hidden) parent item of your secondary menu will be the currently selected primary menu item.
Not the full solution.
Sorry, maybe I was not clear. I know how to do what you just said...
What I want to do is have both second-level AND third-level links exposed when I click on the primary link. Your solution only exposes the second-level.
You might find these useful
I think, in order to get into 3rd (or lower) levels of navigation, you'll have to write something custom in your theme or template.php file. Was just doing a lot of research on this and came across your post. For me I was just showing the second level, so the solution above helps me but doesn't help you.
Here's a list of links/articles/posts/modules/API calls that I found while searching. They might lead you to a solution (these are all Dupal 6 related):
Menu Block
Module for creating blocks representing sublevels of your menu. A bunch of related menu modules are there as well.
menu_tree()
Returns themed HTML output of whatever menu you pass it. (ie.
menu_tree('primary-links')). Note that this is themed, so what you get back may differ depending on modules. In my case, I have the DHTML menu module installed, so my primary-links nav came back with a bunch of extra classes added in by that module so that it ties in with the javascript it uses.menu_tree_all_data()
Returns the raw object of your nav which you can loop through and do whatever you want with. (Note that it returns raw paths, not URL aliases.)
menu_navigation_links()
Returns an object that represents a menu at a given level, so
menu_navigation_links('primary-links',1)will return the secondary level of whatever page/menu item you're currently on. It doesn't return everything at the secondary level, just the child secondary level for the section you're in. (Use "2" instead of one for the third level, etc.)You can theme the results like this:
echo theme('links', menu_navigation_links('primary-links',1), array('class' => 'links primary-links second-level'));(that array at the end are the classes that get applied to the unordered list that is outputted)That last one is the method you probably want to use. I'm not sure about your level of familiarity with Drupal and theming, but I'd probably define a variable in a
phptemplate_preprocess_page()function that would hold your third level, and in your theme, spit out those variables. (more on preprocessing and setting up vars)Example...
Something like that.
I've only been using Drupal for a little while, so I don't know if that's the best, preferred solution, or even the best for your scenario. Hopefully something above will be useful to you!
Oh, and lastly, one thing that I found annoying is that once you're into a child page, the parent page no longer has it's "active" class applied to it. This post has a solution that overrides
theme_links()and adds in an extra class for the parent menu item so you can style it as "active". It might not work in every situation, because the code is using regular expressions to check URLs, and if you're child has a different path than your parent, you may get unexpected results.Anyways, good luck!
Active-trail class
Doesn't the parent page link get an "active-trail" class that can serve the same purpose?
Yea, the parent page does get
Yea, the parent page does get it, but depending on the way your site works, the active-trail class is not a complete solution.
If you're on a child page that exists in your Menu (ex. /section1/subsection1), then "section1" will have the class "active-trail", because subsection1 is a child of it. But if you're at, say, an article page in your section (ex. /section1/subsection1/my_article), then active-trail won't be there, and the second level won't show up, because you're no longer on a page that belongs in the Menu. That's why that guy was checking the URL and the href of the menu item in his code, so he could insert a class.
Sorry, that's what I meant by "child page". I should have been more clear. I didn't mean a logical child page, a child page that appears in the menu, but a pseudo-child page, in that the URL alias makes it look like its a child of your section. :P
Add third-level menu items to
Add third-level menu items to page template: http://drupal.org/node/86890#comment-3772326
THANK YOU!!
This was exactly what I was looking for and you gave me all that I needed so I didn't have to go hunting. Really truly, Thank you!!!