我想在Skeleton Application(ZF2)中构建一个菜单。我制作了一个单独的模块Navigation
。
在Navigation Controller编写了一个代码:
namespace Navigation\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Navigation\Navigation;
class NavigationController extends AbstractActionController
{
public function indexAction()
{
$container = new \Zend\Navigation\Navigation(array(
array(
'label' => 'Album',
'controller' => 'album',
'action' => 'index',
'route' => 'album',
)
));
$navigation = new \Zend\View\Helper\Navigation\Menu();
$navigation->renderMenu($container);
return new ViewModel(array('navigation'=>$navigation));
}}
得到错误:
Zend\Navigation\Page\Mvc::getHref cannot execute as no Zend\Mvc\Router\RouteStackInterface instance is composed
在文件:\ vendor \ zendframework \ zendframework \ library \ Zend \ Navigation \ Page \ Mvc.php:186
如何解决?
答案 0 :(得分:0)
似乎路线“相册”未在导航模块中定义。需要在Navigation模块的module.config.php中设置路由。路径需要包含一个额外的参数:我认为指向应用程序模块的模块。
答案 1 :(得分:0)
从数据库下载ZF2动态导航。有添加,编辑和删除菜单项的功能。