Cannot find the right way to describe sitemap that works with breadcrumbs.
For example i have a navigation described in 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'
)
...
)
)
)
)
),
),
And there i mean it should match patterns like articles/page/1 and articles/page/2 ...
The routes are in 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',
),
),
),
),
),
I need to make dynamic breadcrumb paging. So i tried to add example page from controller
$navi = $this->getServicelocator()->get('Navigation');
$page = $navi->findById('articles');
$page->addPage(
array(
'label' => 'Page 10',
'route' => '10'
)
);
Breadcrumbs were empty at articles/page/10 ? Is not the right way i am doing this ?
You have to change your "navigation" this way ("pages" array empty) :
Then, in your controller action you have to add this code :
Like that, all your pages will have their name into the breadcrumb and not a generic term.
Had a Similar Problem, i could resolve it by using the 'useRouteMatch' - flag