Skip to content

Instantly share code, notes, and snippets.

@kaiohken1982
Created July 30, 2013 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kaiohken1982/6112983 to your computer and use it in GitHub Desktop.
Save kaiohken1982/6112983 to your computer and use it in GitHub Desktop.
Getting breadcrumbs using fragment
public function breadcrumbsAction()
{
$default = 'dashboard';
$id = $this->getRequest()->getQuery('id', $default);
$pos = strpos($id, '/');
$id = false !== $pos ? substr($id, 0, $pos) : $id;
$view = $this->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer');
$navigation = $view->navigation('navigation');
$container = $navigation->getContainer();
$page = $container->findOneBy('fragment', $id);
$page = null === $page ? $container->findOneBy('fragment', $default) : $page;
$page->setActive(true);
$viewModel = new ViewModel(array(
'breadcrumbs' => $navigation->breadcrumbs()->setPartial('breadcrumbs')->setRenderInvisible(true)->setMinDepth(0)
));
$viewModel->setTerminal(true);
return $viewModel;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment