How to add an dumb menu item

edited December 2011 in Modules
I want to add a menu item, that points nowhere (no anchor tag), it has only sub menu items. How to do it using Menu library?

Comments

  • edited 8:12PM
    Try explicitly setting the location value of the menu item to an empty string:
    $nav['my_menu_item'] = array('label' => 'My Menu Item', 'location' => '');
  • edited December 2011
    If I set the location to empty string, the submenus aren't generated. Also I'll have an anchor pointing to the base url.
    To be clear, I generate menu from DB, so I set the location field to empty manually.
    Thanks

    EDIT: I have the submenus from the db query array, but after pushing to render method, they don't generate.
  • edited 8:12PM
    Okay somebody solved it (I also in different way, meantime) so thanks
    http://bit.ly/tDFgkg
  • edited 8:12PM
    Unless I misunderstand, I believe it should work for you if you provide the proper nav key in the admin. So for example, if you create a menu item with the location value as empty but specify the "nav key" to say "blank" and then have all the child menu elements specify their parent value to "blank", it should render the menu with it's children.
  • edited 8:12PM
    I'd like to do that but using only the admin and the fuel_nav() function...

    Basically this kind of already works: you can create a menu item and specify an empty location. This is handled well by the fuel_nav() function as it will generates only a li without the anchror tag.
    The problem is that you can have only one menu item without a location. If you try to add another you will have an "The Location is empty or already exists." error when saving.

    I thought modifying the navigation_model as following will do the trick but creating a new item with an empty location will actually replace the existing one :(

    Any workaround possible?

    function is_new_location($location, $group_id, $parent_id)
    {
    if (empty($group_id)) return FALSE;
    + if ($location == '')
    + return TRUE;
    [...]
    }
  • edited 8:12PM
    The reason why it replaces an existing one is because there is a unique index on the fuel_navigation table.
  • edited 8:12PM
    Ok, I've changed the (group_id, location, parent_id) unique index to normal index.
    It's seems to work well at first sight, I'll play a bit with it in dev...

    Haven't looked for performance loss but since the number of items shouldn't reach more than 20 it shouldn't be a problem.

    Thanks!
Sign In or Register to comment.