ZF2 导航:使用默认参数以外的参数激活路由


ZF2 Navigation: Activate route with parameters other than default?

这似乎是一个类似的问题,但对我不起作用。我觉得答案一定在那里 - 这不可能是一个罕见的问题 - 但我没有使用正确的搜索词。

ZF2:zend 导航中子路由的活动分支。如何?

这是我定义的路线:

'router' => array(
    'routes' => array(
        'platform' => array(
            'type' => 'segment',
            'options' => array(
                'route' => '/platform[/:controller/:region/:id[/:action]]',
                'constraints' => array(
                    'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'region' => '[0-9a-z]{2,4}',
                    'id' => '[0-9a-z-]+',
                ),
                'defaults' => array(
                    'controller' => 'platform',
                    'action' => 'index',
                ),
            ),
        ),
    ),
),

这是我的导航:

'navigation' => array(
    'default' => array(
        array(
            'label' => 'Home',
            'route' => 'home',
        ),
        array(
            'label' => 'Account',
            'route' => 'zfcuser',
            'pages' => array(
                array(
                    'label' => 'Dashboard',
                    'route' => 'zfcuser',
                ),
                array(
                    'label' => 'Sign In',
                    'route' => 'zfcuser/login',
                ),
                array(
                    'label' => 'Sign Out',
                    'route' => 'zfcuser/logout',
                ),
                array(
                    'label' => 'Register',
                    'route' => 'zfcuser/register',
                ),
            ),
        ),
        array(
            'label' => 'Platform v2 BETA',
            'route' => 'platform',
        ),
    ),
),

我在布局中的每个页面上显示一个顶级菜单,如下所示:

                <div class="nav-collapse collapse">
                    <?php echo $this->navigation('navigation')
                                    ->menu()
                                    ->setMinDepth(0)
                                    ->setMaxDepth(0)
                                    ->setUlClass('nav')
                                    ->render(); ?>
                </div>

我的导航显示正确,并为主页和zfcuser路由激活了正确的部分。这是我遇到问题的平台路线。如果我转到/platform菜单将被激活。但是,当我浏览到模块中的任何其他页面时(例如。 /platform/pendulum/na/af455e ) 没有活动菜单,也没有面包屑。问题似乎是这些其他页面上的控制器/操作与路由指定的默认值不同。

如何获得任何成功的路由匹配以激活菜单?

把这样的东西放进去

  'invokables' => array(
        'Application'Controller'Platform'       => 'Application'Controller'PlatformController')

并像这样替换上面的默认值

 'defaults' => array(
                'controller' => 'Application'Controller'Platform',
                'action' => 'index',
            ),

应用程序是我情况下的模块名称