adding a second nav to theme

Is there a way to add a second nav to a theme?

Currently in the header we have
<?php echo public_nav_main(); ?>

Which shows everything we have selected in the appearance->navigation.

But we want the main nav to show home and basically simple pages pages, and a second nav further down specific pages that only shows the collection links related to browse subjects, browse tags etc.

In the admin it only seems possible to create one single navigation structure, is it possible to create two in the admin and then show them seperately?

Any ideas?

It's not something that can be done right from the admin side, but some theme hacking could make it happen.

For the pages where you want the second navigation, you could use nav, and add in something like this:

<nav class='navigation'>
<?php
$secondNavLinks = array(
        array('label' => 'Collection 20', 'uri' => url('collections/20')),
        array('label' => 'Collection 19', 'uri' => url('collections/19'))
        );

echo nav($secondNavLinks, 'second-nav');
?>
</nav>

The tricky part might be figuring out what those links will be if they change for different pages.

OK great thanks, that at least gives me some more options, the problem is what is added in Admin will need to be reflected in Admin but I will have a think around this.

Also im struggling to find documentation on this function public_nav_main();

I presume I can pass an array of things into this function as I have found examples of SetMaxDepth and Role, but no definitive list. Is it possible to pass in the ID and class of the UL elements to overide 'Navigation' as the class etc?

Or do I need to build a new nav using Nav?

Sadly, our documentation on that function is pretty weak. In almost all cases, though, the important thing is that is where the public_name_main filter is applied, so that's how the output can be manipulated. Via the filter you pass in an array just like the example above.

Neither the function itself or the filter let you pass in an array of options, though some methods for changing things are available on the object that's returned. Looks like setUlId() and setUlClass() are available, but that gets you pretty deep into Zend Framework stuff. If it's possible to get what you need without going to those depths, that usually work better.

I couldnt quite my head around how to get this working from an omeka point of view so I delved into the Zend options.

The following works but im not sure if its the best/right way to do things.

So I replaced

echo public_nav_main();

with


$mainNav = public_nav_main();
$mainNav->setUlClass('nav')->setUlId('main-menu-left');
echo $mainNav;

And it works great.