我想在骨架应用程序(ZF2)中建立一个菜单。我创建了一个单独的模块Navigation。在导航控制器上写了一段代码:
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的文件
如何解决这个问题?
发布于 2012-12-11 16:15:16
您的导航模块中似乎没有定义路线“相册”。需要在导航模块的module.config.php中设置路由。路由需要包含一个额外的参数:我认为指向Application模块的module。
发布于 2014-09-29 00:09:01
从数据库下载ZF2动态导航。具有添加、编辑、删除菜单项的功能。
https://stackoverflow.com/questions/13799955
复制相似问题