Skip to content
This repository has been archived by the owner on Feb 11, 2018. It is now read-only.

Commit

Permalink
Merge pull request #24 from florianbelhomme/issue-22
Browse files Browse the repository at this point in the history
Fix issue #22
  • Loading branch information
Florian Belhomme committed Mar 1, 2015
2 parents b945901 + f6c61f7 commit cb67528
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Resources/views/Menu/foundation_breadcrumb.html.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% block root -%}

<ul class="breadcrumbs">
{%- for breadcrumb in breadcrumbs -%}
<li><a href="{{ breadcrumb.uri }}">{{ breadcrumb.label }}</a></li>
{%- endfor -%}
</ul>

{% if breadcrumbs|length > 0 -%}
<ul class="breadcrumbs">
{%- for breadcrumb in breadcrumbs -%}
<li><a href="{{ breadcrumb.uri }}">{{ breadcrumb.label }}</a></li>
{%- endfor -%}
</ul>
{%- endif %}
{%- endblock %}
12 changes: 10 additions & 2 deletions Twig/MenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ public function renderAsBreadcrumb($menu, array $options = array())
$itemFilterIterator = new CurrentItemFilterIterator($treeIterator, $this->matcher);
$itemFilterIterator->rewind();

// Extract the items for the breadcrumb
// Watch for a current item
$current = $itemFilterIterator->current();

$manipulator = new MenuManipulator();
$breadcrumbs = $manipulator->getBreadcrumbsArray($itemFilterIterator->current());
if ($current instanceof ItemInterface) {
// Extract the items for the breadcrumb
$breadcrumbs = $manipulator->getBreadcrumbsArray($current);
} else {
// Current item could not be located, we only send the first item
$breadcrumbs = $manipulator->getBreadcrumbsArray($menu);
}

// Load the template if needed
if (!$options['template'] instanceof \Twig_Template) {
Expand Down

0 comments on commit cb67528

Please sign in to comment.