Zend framework2 使用ZF2实现动态页面面包屑
我想动态呈现属性页的页面面包屑。应该这样看:Zend framework2 使用ZF2实现动态页面面包屑,zend-framework2,breadcrumbs,Zend Framework2,Breadcrumbs,我想动态呈现属性页的页面面包屑。应该这样看: Home>Country name>City name>Property name 使用属性id从数据库中检索国家、城市和属性的名称。我对查询没有问题,但如何将值传递给视图 下面是我的配置站点地图:它只返回Home>Property return [ 'navigation' => [ 'default' => [ 'home' => [
Home>Country name>City name>Property name
使用属性id从数据库中检索国家、城市和属性的名称。我对查询没有问题,但如何将值传递给视图
下面是我的配置站点地图:它只返回Home>Property
return [
'navigation' => [
'default' => [
'home' => [
'label' => 'Home',
'route' => 'home-page',
'pages' => [
'property-page' => [
'label' => 'Property',
'module' => 'application',
'controller' => 'Application\Controller\Property',
'route' => 'property-page',
'action' => 'index'
],
],
],
],
],
];
您可以通过
导航
到服务配置
来实现这一点。大概是这样的:
'navigation' => function($sm) {
$navigation = new \Zend\Navigation\Service\DefaultNavigationFactory;
$navigation = $navigation->createService($sm);
//add here other staff for the navigation
}
$navigation = $this->getServiceLocator()->get('navigation'); //get the navigation
$page = $nav->findByLabel('country')->setLabel($country); //set country value as label
然后,当您从数据库中获取项目时,您可以更改导航
,如下所示:
'navigation' => function($sm) {
$navigation = new \Zend\Navigation\Service\DefaultNavigationFactory;
$navigation = $navigation->createService($sm);
//add here other staff for the navigation
}
$navigation = $this->getServiceLocator()->get('navigation'); //get the navigation
$page = $nav->findByLabel('country')->setLabel($country); //set country value as label
其中,$country
是获取的country proprety值
你可以看到这个和这个来了解更多细节
希望这有帮助