Fuel_nav's regular expression functionality

edited April 2012 in Modules
Hi,

I'm trying to use the fuel_nav() method to generate a (sub) menu which would highlight by CSS class the terminating list element's link (the navigation data is coming from the CMS).

EG if the current url was "/about/staff/vacancies" the HTML rendered would ideally be something like:
<ul id="sub-nav"> <li><a href="/about/staff">Staff</a> <ul><li class="active"><a href="/about/staff/vacancies">Vacancies</a></li></ul> </li> </ul>

I've configured the fuel_nav() array like so:
fuel_nav(array( 'group_id' => 'main', 'parent' => uri_segment(1), 'container_tag_id' => 'sub-nav', 'item_id_prefix' => 'sub-nav_', 'active' => uri_path() ));

and this gives me the menu I want just fine, but it triggers the "active" class name to appear in all the descending <li> elements terminating in the current url link. I'd like it to only apply to the last <li> element (so it can have a unique "on" state). I've tried using only the terminating segment name as the 'active' value, but this does not apply an "active" class anywhere. I've tried some regex like:
'active' => '(/'.$lastseg.')$'

where $lastseg is the terminal uri segment, but that does not work either. Is it possible to effect "active" only on the current url using regex, or am I missing something more elementary?

If the CSS pseudo class :last-child was supported better, that would be a solution.

Comments

  • edited April 2012
    Does the following help:
    fuel_nav(array( 'group_id' => 'main', 'parent' => uri_segment(1), 'container_tag_id' => 'sub-nav', 'item_id_prefix' => 'sub-nav_', 'active' => uri_path(), 'cascade_selected' => FALSE ));
    Note the "cascade_selected" parameter.
  • edited 10:28PM
    Yes. Yes it does. The shame!

    Thanks!
Sign In or Register to comment.