{% extends 'knp_menu.html.twig' %}{% macro attributes(attributes) %} {% for name, value in attributes %} {%- if value is not none and value is not same as(false) -%} {{- ' %s="%s"'|format(name, value is same as(true) ? name|e : value|e)|raw -}} {%- endif -%} {%- endfor -%}{% endmacro %}{% block item %} {# macro inheritance not supported anymore in twig #} {# {% import '@knp_menu/knp_menu.html.twig' as macros %} #} {% if item.displayed %} {%- set attributes = item.attributes %} {%- set is_dropdown = attributes.dropdown|default(false) %} {%- set divider_prepend = attributes.divider_prepend|default(false) %} {%- set divider_append = attributes.divider_append|default(false) %} {# unset bootstrap specific attributes #} {%- set attributes = attributes|merge({'dropdown': null, 'divider_prepend': null, 'divider_append': null }) %} {%- if divider_prepend %} {{ block('dividerElement') }} {%- endif %} {# building the class of the item #} {%- set classes = item.attribute('class') is not empty ? [item.attribute('class')] : [] %} {%- if matcher.isCurrent(item) %} {%- set classes = classes|merge([options.currentClass]) %} {%- elseif matcher.isAncestor(item, options.depth) %} {%- set classes = classes|merge([options.ancestorClass]) %} {%- endif %} {%- if item.actsLikeFirst %} {%- set classes = classes|merge([options.firstClass]) %} {%- endif %} {%- if item.actsLikeLast %} {%- set classes = classes|merge([options.lastClass]) %} {%- endif %} {# building the class of the children #} {%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %} {%- set childrenClasses = childrenClasses|merge(['menu_level_' ~ item.level]) %} {# adding classes for dropdown #} {%- if is_dropdown %} {%- set classes = classes|merge(['dropdown']) %} {%- set childrenClasses = childrenClasses|merge(['dropdown-menu']) %} {%- endif %} {# putting classes together #} {%- if classes is not empty %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- endif %} {%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %} {# displaying the item #} {% set attributes = item.attributes(attributes) %} <li{{ _self.attributes(attributes) }}> {%- if is_dropdown %} {{ block('dropdownElement') }} {%- elseif item.uri is not empty and (not item.current or options.currentAsLink) %} {{ block('linkElement') }} {%- elseif attributes.data is defined and attributes.data == 'search-box' %} {%- else %} {{ block('spanElement') }} {%- endif %} {# render the list of children#} {{ block('list') }} </li> {%- if divider_append %} {{ block('dividerElement') }} {%- endif %} {% endif %}{% endblock %}{% block dividerElement %} {% if item.level == 1 %} <li class="divider-vertical"></li> {% else %} <li class="divider"></li> {% endif %} {% endblock %}{% block linkElement %} <a href="{{ item.uri }}"{{ _self.attributes(item.linkAttributes) }}> {% if item.attribute('icon') is not empty %} <i class="{{ item.attribute('icon') }} hidden-xs"></i> <span class="hidden-sm hidden-lg hidden-md">{{ item.attribute('icon_text')|raw }}</span> {% endif %} {{ block('label') }} {% if item.attribute('linktext') is not empty %} <span class="linktext">{{ item.attribute('linktext')|raw }}</span> {% endif %} </a>{% endblock %}{% block searchForm %} <form class="navbar-form navbar-left searchform" role="search"> <div class="input-group"> <span class="input-group-btn hidden-xs hidden-sm" id="searchbutton" > <button class="btn btn-transparent glyphicon glyphicon-search" type="button"></button> </span> <input type="text" class="form-control searchbox hidden-md hidden-lg" id="searchbox" placeholder="Suche..."> </div> </form>{% endblock %}{% block spanElement %} <span>{{ _self.attributes(item.labelAttributes) }} {% if item.attribute('icon') is not empty %} <i class="{{ item.attribute('icon') }}"></i> {% endif %} {{ block('label') }} </span>{% endblock %}{% block dropdownElement %} {%- set classes = item.linkAttribute('class') is not empty ? [item.linkAttribute('class')] : [] %} {%- set classes = classes|merge(['dropdown-toggle']) %} {%- set attributes = item.linkAttributes %} {%- set attributes = attributes|merge({'class': classes|join(' ')}) %} {%- set attributes = attributes|merge({'data-toggle': 'dropdown'}) %} <a href="#"{{ macros.attributes(attributes) }}> {% if item.attribute('icon') is not empty %} <i class="{{ item.attribute('icon') }}"></i> {% endif %} {{ block('label') }} <b class="caret"></b> </a>{% endblock %}{% block label %}{{ item.label| raw }}{% endblock %}