【发布时间】:2016-10-21 07:28:59
【问题描述】:
找不到正确的方式来描述适用于面包屑的站点地图。
例如,我在 module.config.php
中描述了一个导航'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home'
),
array(
'label' => 'Articles',
'route' => 'articles',
'pages' => array(
array(
'label' => 'Paging',
'route' => 'articles',
'id' => 'articles',
'pages' => array(
array(
'label' => 'Page 1',
'route' => '1'
),
array(
'label' => 'Page 2',
'route' => '2'
)
...
)
)
)
)
),
),
我的意思是它应该匹配 articles/page/1 和 articles/page/2 之类的模式 ...
路由在 autoload/routes.global.php
'articles' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/articles',
'defaults' => array(
'controller' => 'Articles\Controller\Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'pagination' => array(
'type' => 'Segment',
'options' => array(
'route' => '/page[/:page]',
'constraints' => array(
'page' => '[0-9A-Za-z]+',
),
'defaults' => array(
'controller' => 'Articles\Controller\Index',
'action' => 'index',
),
),
),
),
),
我需要制作动态面包屑分页。 所以我尝试从控制器添加示例页面
$navi = $this->getServicelocator()->get('Navigation');
$page = $navi->findById('articles');
$page->addPage(
array(
'label' => 'Page 10',
'route' => '10'
)
);
articles/page/10 的面包屑为空?我这样做不正确吗?
【问题讨论】:
标签: routes zend-framework2 breadcrumbs