Created
March 9, 2012 19:38
knpmenu + twitter bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Builder extends ContainerAware | |
{ | |
public function adminMenu(FactoryInterface $factory, array $options) | |
{ | |
$menu = $factory->createItem('root'); | |
$menu->setChildrenAttribute('class', 'nav'); //esto es el tema | |
$menu->setCurrentUri($this->container->get('request')->getRequestUri()); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% Con dropdown %} | |
{% extends "knp_menu.html.twig" %} | |
{% block list %} | |
{% import "knp_menu.html.twig" as macros %} | |
{% set is_dropdown = listAttributes.dropdown|default(false) %} | |
{% set divider_prepend = listAttributes.divider_prepend|default(false) %} | |
{% set divider_append = listAttributes.divider_append|default(false) %} | |
{# unset bootstrap specific attributes #} | |
{% set listAttributes = listAttributes|merge({'dropdown': null, 'divider_prepend': null, 'divider_append': null }) %} | |
{% if item.hasChildren and options.depth is not sameas(0) and item.displayChildren %} | |
{% if is_dropdown %} | |
<ul{{ macros.attributes(listAttributes)}}> | |
{% if divider_prepend %} | |
<li class="divider-vertical"></li> | |
{% endif %} | |
<li class="dropdown"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ item.label }} <b class="caret"></b></a> | |
<ul class="dropdown-menu"> | |
{{ block('children') }} | |
</ul> | |
</li> | |
{% if divider_append %} | |
<li class="divider-vertical"></li> | |
{% endif %} | |
</ul> | |
{% else %} | |
{{ parent() }} | |
{% endif %} | |
{% endif %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment