1
속성 렌더링 :사용자 지정이처럼 KNP 메뉴 번들에서 사용자 지정 특성을 렌더링 할 수있는 방법이 있나요 뭔가를 KNP 메뉴
나는이 (가) 태그 후 별도의 사업부를 추가하여 linkElement를 오버라이드 (override) 한$menu = $factory->createItem(Role::ROLE_PROGRAM_EVENT_PLANNER, array(
'route' => 'show_form_events',
'attributes' => array('class' => 'menu pe_planner'),
'extra' => array(
'content' => 'my custom content'
)
));
.)
MenuBuilder는
$menu->addChild(
'Dashboard',
array(
'route' => 'dashboard',
'attributes' => array(
'class' => 'navigation-entry'
),
'extras' => array(
'icon' => '6'
)
)
);
menuTemplate
{% block linkElement %}
{% import "knp_menu.html.twig" as macros %}
<a href="{{ item.uri }}"{{ macros.attributes(item.linkAttributes) }}>
<span class="icon">{{ item.getExtra('icon') }}</span>
<span class="entry">{{ block('label') }}</span>
</a>
{% endblock %}
청춘을, 즉 사업부에서 나는 여분의 내용 사실
{% block linkElement %}
{% import _self as knp_menu %}
<a href="{{ item.uri }}"{{ knp_menu.attributes(item.linkAttributes) }}>{{ block('label') }}</a>
{% if item.hasChildren == false %}
<div class="custom">{{ item.getExtra('content') }}</div>
{% endif %}
{% endblock %}
코드로 오류가 발생 했습니까? 내 기억에 나는 비슷한 방식으로 그렇게했다고 말하고 싶습니다. – nixoschu