fuel_nav active class looking to location or nav key?

edited May 2013 in Bug Reports
Hi, let's say I have the following navigation structure:

- Company Part 1
-- Part 1 Home
-- Part 1 etc
- Company Part 2
-- Part 2 Home
-- Part 2 etc.

Basically Company Part 1 and Part 1 Home are referring to the same url, let's say /part1
But for the design I created this structure and using the parent option in fuel_nav.

For Company Part 1 and Part 1 Home, I have to use different Nav Key's because FUEL doesn't allow you to create duplicates. The problem now is that the active class won't work because of these duplicates. So my question is: Is the active class looking to the nav key, or the location to check if the navigation element is the active url?

I should say it should look to the location of the navigation element and compare it with the current url.

Comments

  • edited 5:28AM
    There is a "use_nav_key" parameter you can pass to fuel_nav (was added about a week and a half ago to the 1.0 branch). The default value is set to AUTO, which means if the navigation is created in the CMS, it wil use the nav_key value. You can however set it to "location" so that it will use the location value. Alternatively, you can use the "active" or "selected" (both are acceptable) parameter which takes a regular expression value of the locations/nav_key you want to match as active:
    $nav['company_part1'] = array('label' => 'Company Part 1', 'active' => 'company_part1$|company_part1/home$'); $nav['company_part1/home'] = array('label' => 'Company Part 1 Home');
    There is also a ":children" value you can pass to active/selected which will make that menu item active for anything under "company_part1".
  • edited 5:28AM
    I'm using the navigation created in the CMS.
    In /fuel/modules/fuel/libraries/Menu.php I changed the use_nav_key to 'location' but it doesn't seem to work.

    Matching the current url to the target (location) url instead of nav_key of the navigation item would be more logic to me.
  • edited 5:28AM
    Did you trying setting the selected value in the CMS (under the Advanced tab)?
  • edited 5:28AM
    Ah, I wasn't aware about that option. That works, although it's strange that I have to repeat the location there. Setting it to 'location' as you mention isn't possible?
  • edited May 2013
    My apologies... I mis-informed you about the use_nav_key. That is a boolean value that helps when doing matches for active pages and gets set to true if you are using the CMS since the nav_key value is supplied. To do matching, you need to use the selected/active on the navigation item.
  • edited 5:28AM
    i have used that but still the same except while i am in home page
    echo $nav_arr = fuel_nav(array('depth'=>1
    ,'render_type' => 'basic'
    , 'group_id' => 1
    , 'active_class'=>'active'

    ,'container_tag_attrs' => array('style' => '')
    ,'container_tag_class' => 'nav navbar-nav'
    ,'order' => 'precedence'
    ,'use_nav_key'=>TRUE
    ,'subcontainer_tag_class'=>array('','','')
    ));
    can you please hep me on it
  • edited 5:28AM
    Please explain your problem in detail with some examples of the navigation structure you are trying to use.
Sign In or Register to comment.