There was a bug in zf2 ver <= 2.1.3 about this and its closed but not yet merged into production package and will be fixed in next minor release https://github.com/zendframework/zf2/issues/3976 Simple solution : https://github.com/froschdesign/zf2/commit/454439d35716ed2125a6ac90c826836f57391eb0
Multi navigation failed in layout
-
18-03-2022 - |
Question
why second var_dump() display null in this code in my layout.phtml :
var_dump(($this->navigation('navigation')->menu()->render()));
var_dump(($this->navigation('navigation')->breadcrumbs()->render()));
output :
string '<ul class="navigation">
<li>
<a href="/en/admin">DashBoard</a>
</li>
<li>
<a href="/en/admin/members">Members Management</a>
</li>
<li class="active">
<a href="/en/admin/events">Events</a>
<ul>
<li>
<a href="/en/admin/events/categories">Categories</a>
</li>
<li class="active">
<a href="/en/admin/events">Show All</a>
</li>
<li class="active">
<a href='... (length=802)
string '' (length=0)
EDIT :
actually changing var_dump order ... OMG ... again the second one is NULL !! :-O Output :
string '<a href="/en/admin/events">Events</a> > Show All' (length=51)
string '' (length=0)
Solution
OTHER TIPS
the contents on breadcrumbs will depends where the output is executed.
for example, if you are inside a controller and action which has been assigned to one of your navigation items, then it should be picked up.
I suspect you haven't setup navigation pages for the controller/action pairing where you are performing the var_dump.
Example nav config:
array(
'navigation' => array(
'default' => array(
array(
'label' => 'Page One',
'route' => 'myroute',
'controller' => 'categories',
'action' => 'list',
),
If you perform your output in the listAction method of your Categories controller then the breadcrumb helper should return something for you
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow