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

enky’s picture

Status: Active » Closed (fixed)

to crate custom menus, we can use, menu_primary_links() API function,

like-

print theme('nav', '<a href="#">my menus</a>', menu_primary_links(1, 15)); ?>

Thanks cb921, for helping me out on IRC,

JoshLangner’s picture

Status: Closed (fixed) » Active

Could 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

enky’s picture

you just need to create a menu for 'Products' (with gears, nuts, bolts as menu items)
in the admin/menu page,

then use this

<?php print theme('nav', '<a href="#">Products</a>', menu_primary_links(1, 15)); ?>

assuming the menu id for "Products" is 15.

JoshLangner’s picture

Thanks, 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...

rkerr’s picture

Status: Active » Fixed

Yeah 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.

rw712’s picture

Status: Fixed » Active

Still 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.

rkerr’s picture

The 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...

pulpzebra’s picture

I 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.

mliga’s picture

I 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


function mollio_pm_nav( ){ # POOR MAN MOLLIO NAVIGATION MENU

        $output = "<ul id=\"nav\">\n";
        $mm = menu_get_item( 2 ); // GET THE PRIMARY LINK
        for( $i = 0; $i < sizeof( $mm["children"] ); $i++ ){
                $class = ( $i == ( sizeof( $mm["children"] ) - 1 )) ? "first" : ( ( $i == 0 )?"first":"");
                $output .= "<li" . ( $class ? ( " class=\"" . $class . "\"") : "" ). ">" . menu_item_link( $mm["children"][$i] ) . "\n";
                $cur = menu_get_item( $mm["children"][$i] );
                if( sizeof( $cur["children"] ) > 0 ){
                        $output .= "<ul>";
                        for( $j = 0; $j < sizeof( $cur["children"] ); $j++ ){
                                $class = ( $j == (sizeof( $cur["children"] ) - 1 )) ? "last" : ( ( $i == 0 )?"first":"");
                                $output .= "<li" . ( $class ? ( " class=\"" . $class . "\"") : "" ) . ">" . menu_item_link($cur["children"][$j]) . "</li>\n";
                        }
                        $output .= "</ul>\n";
                }
                $output .= "</li>\n";
        }
        $output .= "</ul>\n";

        return $output;
}

and then I add in the page.tpl.php in the "header" div, right after the

tag:

     print mollio_pm_nav( ); 

It worked for me so I decided to share it.

mcurry’s picture

Why 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.

rkerr’s picture

Status: Active » Fixed

Good catch. Updated 4.7 and HEAD versions in CVS to use variable_get's as suggested.
Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)