-
Notifications
You must be signed in to change notification settings - Fork 25
Zend\Navigation\AbstractContainer->hasChildren() does not seem to work correctly #58
Comments
@andreidiaconescu Thanks! |
The piece of code which may have a problem is:
The method current() returns:
So $this->current()->hasPages() returns true if current child of current page has pages; Providing a code example is a bit harder, as the app is a bit large, and for navigation, it has a factory, navigation template, another the template where helper is used show the menu, etc. Is what i wrote enough or you need a code example ? |
code sample:
|
Here you can find an old related issue: zendframework/zendframework#4517 |
And a working example: <?php
/**
* @var \Zend\View\Renderer\PhpRenderer $this
* @var \Zend\Navigation\Navigation $container
*/
?>
<ul>
<?php foreach ($container as $page): ?>
<li>
<?= $page->getLabel() ?>
<?php if ($page->hasPages()): ?>
<ul class="sub-menu">
<?php foreach ($page as $child): ?>
<li>
<?= $child->getLabel() ?>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</li>
<?php endforeach ?>
</ul> |
Btw. you can simplify this: $this->navigation('admin_navigation')->menu()->setPartial(array('partials/admin-menu', ''));
echo $this->navigation('admin_navigation')->menu(); with: <?= $this->navigation('admin_navigation')->menu()->setPartial('partials/admin-menu') ?> |
thanks a lot ! |
Hello,
After trying for a few hours to make the zend navigation work, when upgrading from ZF2(2.4) to ZF3, i think i have found a problem with method:
Zend\Navigation\AbstractContainer->hasChildren()
In the past it used to work like this (in ZF 2.4):
Now it does not work like this, but does the following:
Is this a problem or not ?
Thank you !
The text was updated successfully, but these errors were encountered: