Using fuel_nav() with Bootstrap

Hi

I've been playing with fuel_nav() to display a Fuel navigation group as a set of Bootstrap buttons - with some difficulty.

I think, in the same way that fuel_nav() has options for container_tag_attrs, it would be really useful to have an item_attrs option too.

Additionally, there's an issue with using item_tag='button' in that the resulting HTML puts the <a> anchor inside the <button> - which renders it unclickable.
<button class="btn"><a href="link">test</a></button>
By setting item_tag='', I can get a list of <a> anchors - which is fine but I need to be able to set the anchor class="btn" and role="button" for Bootstrap compatibility. Currently, I'm doing this via javascript once the page is loaded - it's a bit messy.
<a href="link" class="btn" role="button">test</a>
It would, therefore, be handy to have the item_attrs option as a generally useful thing but also to allow all the item specific options to cascade down into the anchors if item_tag=''.

Hope that makes sense...

Comments

  • edited 9:19PM
    You are right in that there isn't a way to batch assign attributes on the menu link but you can do that via the "attributes" parameter on the actual menu item. Below is an example if it is handled via the nav.php file (there is an "Attributes" field in the CMS if it is controlled there):
    $nav['mypage'] = array('label' => 'My Page', 'attributes' => 'class="btn" role="button"');
  • Indeed. I've done this elsewhere successfully. The drawback is that the method precludes re-use. For example, I may use the fuel_nav() to create a dropdown menu in one location and an array of buttons elsewhere. The required attributes would be different in both cases...
  • edited 9:19PM
    Good suggestion. Will have to take a look at it. Or if you come up with a solution, just send a pull request and we can review and merge in.
Sign In or Register to comment.