I have a client with a Drupal 5.1 site. (Upgrading is not an option.) Their primary nav is in the header with each sections secrondary nav on the left hand side.
What they want is to have each primary navigation item display the next level down (and only one level down) of navigation in a drop-down menu.
For example, say there are three sections (primary navigation items) in the site: About, Resources, and Contact Info.
The About section has the following structure:
About
- Who we are
- History
- prior to '99
- after '99
The Resources section has the following structure:
Resources
- Links
- Good sites
- Bad sites
- Ugly sites
- Documentation
And the Contact Info section is just the one page of contact information.
What they would want is "Who we are" and "History" to show up in a drop-down menu when hovering over About, "Links" and "Documentation" to show up when you hover over Resources, and nothing to show up when hovering over Contact Info.
There is to be no change to how the left navigation works. (Yes, this will result in some duplicate navigation items.)
Oh, and the drop down items need to be dynamically created to match any additional pages the client adds to the site.
I have found where the header info is set. the line of code is:
echo $primary_nav
However, I can not seem to find where the variable $primary_nav is first populated. I'm assuming that I need to in order to make this change.
Does anyone have any ideas for me as to how to go about doing this, or where to look? I've looked in a lot of places so far.
Comments
Why not just search for
Why not just search for $primary_nav in project files?
HillsWeb.com
Hills Web
I've done that and only
I've done that and only found one reference, but it's just as ambiguous as the first one I found.
The first reference is very
The first reference is very straightforward, and the second reference you've mentioned probably holds all the answers
HillsWeb.com
Hills Web
The first reference would be
The first reference would be strait forward if I could find any other meaningful reference to the same varriable.
The second reference is:
$vars["primary_nav"] = str_replace("-active", "-active active", theme('links', $vars["primary_links"], array('class' => 'links primary-links')));
It doesn't directly reference the first variable, but it's the closest thing I could find.
This is beyond frustrating
I just realized that the
I just realized that the indentation didn't go through into the origonal post. The example should read more like:
About
- Who we are
- History
- - prior to '99
- - after '99
Resources
- Links
- - Good sites
- - Bad sites
- - Ugly sites
- Documentation
Maybe I don't really
Maybe I don't really understand what you're asking, but just go to admin/build/menus and add or remove items to the primary links menu.
Pages can be added to menu's directly from the node/edit form (in the "menu settings" fieldset).
For dropdowns see http://drupal.org/project/nice_menus
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
What I'm trying to do is
What I'm trying to do is change an existing menu (not add any pages or anything) to be a hybrid of a left-nav and drop-down menu.
I was just wondering if anyone knew where I would look to find out where the menu items were generated so I could change them.
Drupal's administration interface will not let me do what I am wanting to do and the nice_menus module looks like it's working but whatever menu construct has already been put in place appears to be over-riding the module's behaviour.
I'll just keep looking.
I came across this little
I came across this little tid bit:
$menuhtml = theme_menu_tree(0);
print $menuhtml;
What that code outputs (when added to you page.tpl.php file) is almost what I'm looking for, except it generates a list that includes all items below the active page.
I could swear I saw the words "theme_menu_tree" somewhere in my searching, but now can't seem to find it again. (Brain fried.)
Does anyone know where that function is located?
theme_menu_tree === "Give a
theme_menu_tree
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
Thanks. For some odd reason
Thanks. For some odd reason I got it in my head that the include files were all xml and didn't bother searching them. Yup, brain fried indeed. I think I'll look into this one tomorrow.
After looking over the
After looking over the varrious menu functions I decided that I would first try to install nice_menus to see how that opperates and figured that it might be easier to just modify that (after all, PHP is not my native language). After installing and setting all the varrious configuration settings in the administration section, I proceded to view the site.
No change.
I thought, perhaps I need to first disable the current menu system, so I commented out the "echo $primary_nav;" line and then had no menu.
I'm assuming I'm missing a step somewhere that is not in the nice_menu instalation instructions, but I can't figure out what step that is. Any thoughts?
hmmm... i seem to remember
hmmm... i seem to remember installing nice_menus was straight forward and went without a hitch for me. You enabled the block at admin/build/block? Maybe you have to set the drop downs (i forget what they're called, but there's only 2) at admin/build/menu/settings to be the same menu? Maybe your theme doesn't support primary/secondary menus (i don't think they all do by default)?
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
I'm not sure I know what you
I'm not sure I know what you mean by "setting the drop downs".
What I did was:
- I copied over the nice_menu folder to two directories (I am not sure which it's going to look for); to both mysite/modules and mysite/sites/all/modules (I had to create the directory for the last as "all" did not have a modules directory).
- I enabled the module and configured the module settings to have 9 menus (one for each main section on the site in case I needed to alter the style of one but not the rest).
- I then configured the blocks making each menu a "drop" type, selecting the appropriate parent menu, and then added them all to the header block (region?)
- Then I tried to see the results, and saw what was described previously (nothing).
I really hope this has nothing to do with the theme. The theme I am working with is a custom built one that I did not create at all, and I don't have a clear understanding of them yet. (I'm working on that.)
I think in the end I will just have to create this from scratch. I had just thought that there might be a shortcut as this has a due date attached to it. :(
Okay, I have the drop down
Okay, I have the drop down menu working, except for the fact that it's currently using the nodes instead of the URL alias's for the address of each page. What I now need to do is go through the array of menu items and replace the "path" with the alias.
Is there a global Drupal variable that contains the alias for each page, or am I going to have to do a database lookup?
And it's done. (I did a
And it's done. (I did a database lookup.) Thank you to everyone who helped.