Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there a way to add custom dropdown menus to the navigation bar,
that gets ACTIVE css class, like the primiary or seconday menus?
what i meant is:
<?php if ($secondary_links): ?>
<?php print theme('nav', '<a href="#">Secondary</a>', $secondary_links); ?>
<?php endif; ?>
<?php print theme('nav', '<a href="#">My Menus</a>', $mymenu_links); ?>
?>
How do I get the $mymenu_links variable, which API function to use?
Comments
Comment #1
enky CreditAttribution: enky commentedto crate custom menus, we can use, menu_primary_links() API function,
like-
Thanks cb921, for helping me out on IRC,
Comment #2
JoshLangner CreditAttribution: JoshLangner commentedCould you explain a little further please? I'm trying to do the same thing, or at least something similar. For example, I need the primary links listed along the top (such as "Home | Products | Services | About") and each with secondary link dropdowns, such as "Products > Gears | Nuts | Bolts".
Thanks
Comment #3
enky CreditAttribution: enky commentedyou just need to create a menu for 'Products' (with gears, nuts, bolts as menu items)
in the admin/menu page,
then use this
assuming the menu id for "Products" is 15.
Comment #4
JoshLangner CreditAttribution: JoshLangner commentedThanks, but we worked out a new version of the Mollio menu in the CVS that will loop through and generate all of your menus for you. Check it out in the latest CVS...
Comment #5
rkerr CreditAttribution: rkerr commentedYeah the 4.7 and HEAD (CVS) versions of Mollio should use the primary links menu correctly now. And you can disable the normal primary/secondary links, and add the "primary links" menu block to the header region.
Comment #6
rw712 CreditAttribution: rw712 commentedStill having issues with getting the menus to appear. Looks like template.php:mollio_menu_tree looks to see if the $pid is 2 before adding the id tag "nav". Unfortunately, that fails for me as $pid is 98. Had to change the 2 to 98 to get this to work for me. Can't use the catch-all else case cause other menus will not work.
Comment #7
rkerr CreditAttribution: rkerr commentedThe default "primary links" menu is has id = 2... so you're using a completely different menu as your primary links? I don't know if there's any way around that other than editing the template.php as you did..
Maybe doing a variable_get('menu_primary_menu') ... or checking the blocks configuration would make it easier for non-standard configurations. Or maybe it should just be documented in the README...
Comment #8
pulpzebra CreditAttribution: pulpzebra commentedI just installed the CVS version of Mollio (and CVS files correspond to the latest version), but there's no hint of what you're talking about in this issue. Furthermore, the Horizontal menu simply doesn't display any values associated to it.
Comment #9
mliga CreditAttribution: mliga commentedI just made a quick hack, I know it's not the right way to do it, but I needed to solve this issue fast, so i just add in template.php this code
and then I add in the page.tpl.php in the "header" div, right after the
tag:
It worked for me so I decided to share it.
Comment #10
mcurry CreditAttribution: mcurry commentedWhy use hardcoded pids for primary/secondary menus in template.php/mollio_menu_tree()?
the variable table contains these values:
'menu_primary_menu', 's:1:"2";'
'menu_secondary_menu', 's:2:"83";'
definitely should be using variable_get() here.
Comment #11
rkerr CreditAttribution: rkerr commentedGood catch. Updated 4.7 and HEAD versions in CVS to use variable_get's as suggested.
Thanks!
Comment #12
(not verified) CreditAttribution: commented