php Pimcore Navigaton面包屑

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Pimcore Navigaton面包屑相关的知识,希望对你有一定的参考价值。

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");
	}

	
}

以上是关于php Pimcore Navigaton面包屑的主要内容,如果未能解决你的问题,请参考以下文章

使用 php 脚本将 pimcore 中的现有数据对象导出到 XML 文件

Pimcore:如何覆盖内置控制器

Pimcore 内存限制错误

Pimcore 与树枝;根据菜单深度渲染 html

Pimcore 5:以编程方式将块添加到Areablock(文档自动化)

Pimcore 5:从 4.6.2 升级到 5.0 后卡在维护模式