Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using knp-menu with Bootstrap #6

Open
larry-tx opened this issue Nov 3, 2015 · 5 comments
Open

Using knp-menu with Bootstrap #6

larry-tx opened this issue Nov 3, 2015 · 5 comments

Comments

@larry-tx
Copy link

larry-tx commented Nov 3, 2015

I'm trying to use gourmet/knp-menu with Bootstrap 3, but I need to add certain classes and other attrigutes to the ul and li elements within the structure. For example:

<ul class="nav navbar-nav">
   <li><a href="#">Home</a></li>
   <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Web
                                        Development <b class="caret"></b></a>
      <ul class="dropdown-menu">
         <li><a href="#">Color Charts</a></li>
         <li><a href="#">Html Entities</a></li>
         <li><a href="#">Computer Resources</a></li>
         <li><a href="#">Assist</a></li>
      </ul>
   </li>
</ul>

The knp-menu-bundle provides four methods:

  • setAttribute('attribute_name', 'attribute_value')
  • setChildrenAttribute('attribute_name', 'attribute_value')
  • setLinkAttribute('attribute_name', 'attribute_value')
  • setChildrenAttribute('attribute_name', 'attribute_value')

I can't get these to work with your extension. Do you have plans to incorporate them into your extension? In addition, do you have plans to add some way to include a span or b element, as used in the example above () which is necessary to add the dropdown arrow?

@Phillaf
Copy link

Phillaf commented Nov 3, 2015

There is an issue (see #5) with setChildrenAttribute() that can be fixed by using Knp's default renderer like this:

$this->Knp->render('my_menu', ['renderer' => '\Knp\Menu\Renderer\ListRenderer']);

The other methods are working fine here. How do you call them?

@Phillaf
Copy link

Phillaf commented Nov 3, 2015

For a full example on how to build complex bootstrap menus. Have a look at this renderer and this helper

I use them to build sidebars for almasaeed2010/AdminLTE

@larry-tx
Copy link
Author

larry-tx commented Nov 3, 2015

Thanks for the prompt response. I did get the methods working. My apologies; I was attempting to use them incorrectly. I really like the helper. It will be very helpful as I’m also starting to implement AdminLTE. I’m looking forward to having a plugin for it.

From: Philippe Lafrance [mailto:[email protected]]
Sent: Monday, November 2, 2015 9:48 PM
To: gourmet/knp-menu [email protected]
Cc: LarryTX [email protected]
Subject: Re: [knp-menu] Using knp-menu with Bootstrap (#6)

For a full example on how to build complex bootstrap menus. Have a look at this renderer https://github.com/gintonicweb/admin-theme/blob/master/src/Menu/Renderer/ListRenderer.php and this helper https://github.com/gintonicweb/admin-theme/blob/master/src/View/Helper/MenuHelper.php

I use them to build sidebars for almasaeed2010/AdminLTE https://github.com/almasaeed2010/AdminLTE


Reply to this email directly or view it on GitHub #6 (comment) . https://github.com/notifications/beacon/AABRB-ju5tWssNFc9BirgPIOPqhQm35qks5pCCXegaJpZM4Gam3o.gif

@larry-tx
Copy link
Author

Is there any chance you could post/send a full example of how you use your helper and renderer with AdminLTE. I hope I'm not be too dense, but somehow I can't seem to get the thing to work. I've tried examining your code closely, but just can't get it to work.

@Phillaf
Copy link

Phillaf commented Nov 12, 2015

For support you can come and discuss it in the #gourmet channel on freenode, I'm here right now
https://webchat.freenode.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants