Rendering a breadcrumb with menu in Twig
sschueller opened this issue · comments
Stefan commented
Hi,
I am trying the render the following in twig and I wanted to get some feedback on what would make most sense.
A breadcrumb needs to be rendered and the last item (current) is a dropdown toggle which opens a list of the parents children.
What I do right now is render a custom breadcrumb and call a knp menu at the end item but it maybe the cleaner to do this all in one template? Does anyone have any recommendations of how I could do this in one template?
The menu tree:
Root
|- Item 1
|- SubItem 1
|- SubItem 2
|- 2ndSubItem 1
|- 2ndSubItem 2
|- SubItem 3
|- Item 2
|- Item 3
|- Item 4
Output (when at SubItem 1):
<ol class="breadcrumb">
<li><a href="#">Item 1</a></li>
<li>
<a href="#" class="dropdownopenclose">SubItem 1</a>
<ul class="dropdownmenu">
<li><a href="#" class="active">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 3</a></li>
<li><a href="#">Item 4</a></li>
</ul>
</li>
</ol>
Output (when at 2ndSubItem 1):
<ol class="breadcrumb">
<li><a href="#">Item 1</a></li>
<li><a href="#">SubItem 2</a></li>
<li>
<a href="#" class="dropdownopenclose">2ndSubItem 1</a>
<ul class="dropdownmenu">
<li><a href="#">SubItem 1</a></li>
<li><a href="#" class="active">SubItem 2</a></li>
<li><a href="#">SubItem 3</a></li>
</ul>
</li>
</ol>