gourmet / knp-menu

CakePHP 3 plugin to support KnpMenu
MIT License
14 stars 3 forks source link

Using knp-menu with Bootstrap #6

Open larry-tx opened 9 years ago

larry-tx commented 9 years ago

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:

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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:notifications@github.com] Sent: Monday, November 2, 2015 9:48 PM To: gourmet/knp-menu knp-menu@noreply.github.com Cc: LarryTX LarryTX@outlook.com 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 https://github.com/gourmet/knp-menu/issues/6#issuecomment-153232769 . https://github.com/notifications/beacon/AABRB-ju5tWssNFc9BirgPIOPqhQm35qks5pCCXegaJpZM4Gam3o.gif

larry-tx commented 9 years ago

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 commented 9 years ago

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