Submenu for each page

edited February 2011 in Share
Right now we are trying to implement a simple cms website using fuelcms. And I am stuck at showing a submenu on a page.
The problem is like this I have the
main menu:
1. A
2. B
3. C

For page A accessed form the above main menu I have on the left page a submenu with the following entries:

1. A1
2. A2
3. A3

I am using just one view for the all the menus content pages above.
I call the submenu like this:
<?php print fuel_nav(array('group_id' => 'categ', 'container_tag_id' => 'smenu', 'parent' => '8')); ?>
The problem is that because I specify the parent the when I am in the B page I am still getting the submenu from A.
What I am doing wrong?? I want to use the admin part to create the menu and the submenus for the website.

I have looked at the documentation and the blog but I was not able to find something about this.
Thanks

Comments

  • edited February 2011
    And 8 is the id of the parent location you want to start the menu at for the B page (e.g. B id = 8)? Or is 8 the id of the A menu item? If A is the id of the A menu item, then that is where the problem is. Instead of hard coding in the number, you can use URI segments like so:
    <?php print fuel_nav(array('group_id' => 'categ', 'container_tag_id' => 'smenu', 'parent' => ur_segment(1)); ?>
    In this case, it will do a lookup in the database for the correct id associated with the uri_segment, then assign the parent to that ID value before rendering the menu.
  • edited 10:53PM
    8 is the id of menu A. I have used the core provided by you but with uri_segment but on page B corresponding to the B menu I am still getting the submenu corresponding to A. And to make it simple this is the URL of the page:
    http://dev.hype.ro/fuelcms/
    BRUGER menu is having the ID 8 when accessing the HJÆLPER page I am still getting the submenu of BRUGER.
  • edited 10:53PM
    Any chance you can send me the _variables/nav.php file or SQL dump for the navigation (my email address is under my profile if you click the picture)?
  • edited 10:53PM
    I have found a way not sure is the right one but it works:

    <?php
    $this->db->select('*')->from('fuel_navigation')->where('nav_key', uri_segment(1))->limit('1');
    $query = $this->db->get();
    if($query->num_rows() > 0)
    {
    $query = $query->row();
    $submenuID = $query->id;
    }
    $submenu = fuel_nav(array('group_id' => 'categ', 'container_tag_id' => 'smenu', 'parent' => $submenuID));
    ($submenu != "" ? print $submenu : print " ");
    ?>
  • edited 10:53PM
    I'm glad you were able to get it to work. However, I'd like to make it easier for you. The fuel_nav() function "should" do that querying for you to determine the parent id based on the uri_segment. If you go to the fuel/modules/fuel/helpers/fuel_helper.php file to around line 340, you'll see some logic in there where it will test if the parent is a string, then it will do a lookup. I'd be curious as to what is showing up for you in this case if it is able to find a $parent value (line 343).
  • edited May 2013
    I'm running version 1.0. When I use this code:
    <?php echo fuel_nav(array('container_tag_id' => 'sidemenu', 'parent' => uri_segment(1))); ?>
    It doesn't work, if I use a page id, say 6. It will work. I looked into the fuel/modules/fuel/helpers/fuel_helper.php file around line 340.

    I only see $val = eval_string($val); there, no search for the id of the uri_segment.
  • edited 10:53PM
    Okay solved, the problem was: The nav key was /mediation and the uri-segment result was mediation. I removed the / in the navigation module and it worked fine.
Sign In or Register to comment.