1
目前我在玩与Zend导航在ZF2和我在我的应用程序模块中遇到以下问题ZF2导航与骨架默认路由
我有以下的配置(默认骨架APP)
....
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
'info' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/phpinfo',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'info',
),
),
),
),
),
....
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home',
'order' => -1,
'pages' => array(
array(//<-- this isn't working gives a link to /application
'label' => 'Telefoonboek',
'route' => 'application',
'module' => 'application',
'controller' => 'telefoonboek',
'action' => 'index',
),
array(//<-- this works
'label' => 'Telefoonboek2',
'uri' => '/application/telefoonboek',
),
array(//<-- this works
'label' => 'info',
'route' => 'info',
),
),
),
),
),
....
我目前只能在我为菜单中的“每个”项目添加路线时才能进行导航工作。但这是一种奇怪的解决方案。
那么,这是正确的方式来使菜单工作,或者我需要做一些与网页的幻想吗?
我真的得到它自己工作:)而不是使用父(应用程序)路线我需要指向它的儿童路线应用程序/默认问题解决 – Ponsjuh 2013-03-20 19:23:09
发布为答案;)为更快的引用其他用户。 – Sam 2013-03-21 07:54:57