Skip to content

Instantly share code, notes, and snippets.

@gbili
Created April 6, 2013 14:49
Show Gist options
  • Save gbili/5326345 to your computer and use it in GitHub Desktop.
Save gbili/5326345 to your computer and use it in GitHub Desktop.
Error argument to getActive($active->getChildren()) is NULL whereas $active->hasChildren() is true :/
<ul class="breadcrumb">
<?php
function getActive(array $level) {
$activeInLevel = array_filter($level, function ($page) {
return $page->isActive(true);
});
return $activeInLevel[0];
}?>
<?php $p = $this->pages ?>
<?php $active = getActive($p); echo get_class($active); ?>
<?php while ($active->hasChildren()) : ?>
<li>
<a href="<?= $active->getHref() ?>"><?= $active->getLabel() ?></a>
<span class="divider">/</span>
<li>
<?php $active = getActive($active->getChildren()) ?>
<?php endwhile ?>
<li>
<?= $active->getLabel() ?>
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment