Stas
7/13/2018 - 1:50 PM

Pimcore Navigaton Breadcrumb

Pimcore Navigaton Breadcrumb

Load in Layout:

echo $this->action("breadcrumb", "navigation", null, array( 'document' => $this->document, 'languageRoot' => $this->getProperty('languageRoot') //LanguageRoot Property = 'de' or 'en' Document ));

--- If the page is a Object Detail Document (with Static Route) add this Page to Breadcrumbs --- $this->placeholder('addBreadcrumb')->set([ 'parentId' => $this->document->getId(), 'url' => $this->document->getFullPath(), 'label' => $this->event->getName() ]);

<?php
/*
Folder: /views/scripts/navigation/partials/breadcrumb.php
*/
?>
<?php foreach($this->pages as $pagekey => $page) {
    $active = false;
    if( $pagekey >= count($this->pages) - 1 ){
        $active = true;
    }
    ?>
    <li class="<?= $active ? 'active' : '' ?>" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
        <?php if($pagekey >= count($this->pages) - 1) { ?>
            <?= $page->getLabel() ?>
        <?php } else { ?>
            <a itemprop="url" href="<?= $page->getUri() ?>">
                <span itemprop="title"><?= $page->getLabel() ?></span>
            </a>
        <?php } ?>
    </li>
<?php } ?>
<?php
/*
Folder: /views/scripts/navigation/breadcrumb.php
*/
    $navigation = $this->pimcoreNavigation()->getNavigation($this->document, $this->languageRoot);

	if( $this->placeholder('addBreadcrumb') != '' ){
		$breadcrumbs = $this->placeholder('addBreadcrumb');
		foreach( $breadcrumbs as $breadcrumb ){
			$parentPage = $navigation->findBy('id', $breadcrumb['parentId']);
			$parentPage->addPage(Zend_Navigation_Page::factory([
			    'uri' => $breadcrumb['url'] != '' ? $breadcrumb['url'] : '',
			    'label' => $breadcrumb['label'],
			    "active" => true
		    ]));
		}
	}


    $this->navigation()->menu()->setUseTranslator(false);
    $this->navigation($navigation);

?>

<nav class="breadcrumbs row">

    <div class="col-xs-6">

        <ol class="breadcrumb">
            <?= $this->navigation()->breadcrumbs()->setMinDepth(null)->setPartial("/navigation/partials/breadcrumb.php") ?>
        </ol>

    </div>

</nav>
<?php
/*
Folder: /controllers/NavigationController.php
*/
class NavigationController extends Website_Controller_Action {


	public function breadcrumbAction () {
		$this->view->document = $this->getParam("document");
		$this->view->languageRoot = $this->getParam("languageRoot");
	}

	
}