Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
knpmenu + twitter bootstrap
<?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());
...
{% 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
You can’t perform that action at this time.