While testing out a theme I noticed that the Exhibit plugin handles the “active” class of its navigation as I would expect – as you visit subpages of the Exhibits, up through until navigating to a direct Item view/show page, the primary navigation hyperlink will retain its active class.
It seems as though the core Omeka navigational elements don’t seem to do this (checked thus far: “Browse Collections” and “Browse Items”). While looking through the code, I can see that the Zend Framework was used to generate the navigation. Unfortunately my head’s starting to spin trying to determine the easiest way to modify this so that things would behave as I’d expect (I realize at some point “Browse Collections” would eventually change and the parent would become “Browse Items” as a user navigated through the available paths).
I haven’t really seen any elegant solutions to this out there on the web and thought I’d ask directly to see if perhaps some knowledge of the inner workings of the core system might offer some potential ideas.
What exactly are you looking for those links to do in terms of being active? (As in, on what pages do you think the “parent” link should be active or not active, different from what they do currently?)
I’m currently using Daniel-KM’s fork of gsbodine’s Bootstrap Omeka theme (https://github.com/Daniel-KM/omeka-bootstrap). I’m finding that the only pages where primary navigation (ex: Browse Images, Browse Collections) keep an active class are on its main pages. Once navigated away anywhere else it loses its active class.
I’m looking to see if I could get it to where the following occurs:
- Clicking on a collection record keeps “Browse Collections” link’s active class set
- Clicking on an item within a collection would switch to “Browse Items” having an active class (makes sense hierarchically)
- Browse Collections: /collections/browse
- Collection selected: /collections/show/<collection_id>
- …from here it’s “browse items in collection”, view an item, or choose a sub-collection (same URL structure) from the collection tree
- Click on an item from anywhere and “Browse Items” gains the “active” class setting as defined in the theme
- EXCEPTION: Exhibits (in this theme…only?) has its own item-show page and therefore retains active status in navigation
- Browse Items: /items/browse ([browse|tags|search|map])
- View item: /items/show/<item_id>
I thought I’d be able to find how to do this properly on my own and supply a fix for the theme, but am unsure of just how to go about it.
I should probably add that this theme uses the core library’s
public_nav_main() method to generate the navigation menu.
The basic problem is that “activeness” is matching based on the leading part of the URL matching. So, thinks under “exhibits” work correctly for you because the link for exhibits is just “exhibits” and everything within an exhibit starts with that string in the URL. For items, the nav link is “items/browse,” while the individual item pages are “items/show/xx” so they don’t match up.
One easy solution is to un-check the default Items/Collections/whatever pages from the Navigation admin page and add your own custom nav links that go to just “items” (without the “/browse”). That will still go to the browse page, and will cause all “items” URLs to make the nav item active.