2013-02-28 73 views
1

如何使用Zend Navigation和Breadcrumbs視圖助手在ZF2中使用動態內容創建麪包屑?例如:帶有動態內容的ZF2麪包屑

首頁 - >人物 - >李四

在這種情況下,「李四」是當前正在查看其裝有像/人URI的個人資料頁/ 23424,其中最後一個參數是該人的身份證(可能有數千人)。

我該怎麼做,因爲所有的導航頁面都是在服務配置中創建的?

回答

4

添加導航到服務的配置:

'navigation' => function($sm) { 
    $navigation = new \Zend\Navigation\Service\DefaultNavigationFactory; 
    $navigation = $navigation->createService($sm); 
    /** 
    * Do extra work here with the nav at instantiate time.. 
    */ 
}, 

或者更簡單地說:

'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory' 

現在你可以獲取你想要改變這樣的項目:

$nav = $this->getServiceLocator()->get('navigation'); 
$page = $nav->findByLabel('My Label'); 
$page->setLabel('New Label'); 
0

您可以使用會話並將麪包屑存儲在那裏。你可能想限制自己說10頁。