Build navigation from config:

从配置构建导航:

'navigation' => array(
    'default' => array(
        'admin' => array(
                'label' => 'Administration',
                'controller' => 'index',
                'action' => 'index',
                'route' => 'admin/default',
              ),
         'album' => array(
                'label' => 'Album',
                'controller' => 'index',
                'action' => 'index',
                'route' => 'album/default',
              ),
  /* ... */

Routing is configured like it is true. Navigation in the menu works. Links menu lead to the desired controller/action of the desired module. But while introducing menu and a transition to one or another menuitem, active marked both points simultaneously and 'Administration' and 'Album'. As I understand it, for the reason that match the names of controllers and actions with them, but there's still the 'route' and it's different... not for nothing that the generated different url for each item... but somehow, despite this, they both are marked as active.

路由被配置为真实的。菜单中的导航功能。链接菜单导致所需模块的控制器/动作。但是,在介绍菜单和向一个或另一个菜单项过渡的同时,活动同时标记了两个点,以及“管理”和“相册”。正如我所理解的,原因是控制器和操作的名称与它们相匹配,但是仍然有“路由”,而且是不同的……并不是说每个条目都有不同的url……但是不管怎样,尽管如此,它们都被标记为活动的。

Routing config:

路由配置:

    'router' => array(
    'routes' => array(
        'admin' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/admin',
                'defaults' => array(
                    '__NAMESPACE__' => 'Admin\Controller',
                    'controller'    => 'Index',
                    'action'        => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route'    => '/[:controller][/:action[/id:id]]',
                        'constraints' => array(
                            'controller'    => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action'        => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'id'            => '[0-9]+',
                        ),
                        'defaults' => array(
                        ),
                    ),
                ),

Album routing config similar...

专辑路由配置类似的…

Why this is happening? Thanks.

这是为什么呢?谢谢。

2 个解决方案

#1


0

Looks like it's how ZF2 works (read isActive() function in Zend\Navigation\Page\Mvc.php). Initially it checks matching of route/controller/action, but if it fails, ZF2 again check for just controller/action pair. So there are three possible ways:

看起来ZF2是如何工作的(读isActive()函数在Zend\导航\页面\ \Mvc.php)。最初它检查路由/控制器/动作的匹配,但如果失败,ZF2再次检查是否只有控制器/动作对。所以有三种可能的方法:

  1. Open a ticket at https://github.com/zendframework/zf2/issues and wait for response.

    在https://github.com/zendframework/zf2/issues上打开一个票据,等待响应。

  2. Override \Zend\Navigation\Page\Mvc.

    覆盖\ Zend \页面导航\ \ Mvc。

  3. Choose different names for controllers (and don't use index name because it's default name for controller in Mvc.php).

    为控制器选择不同的名称(不要使用索引名称,因为它是Mvc.php中控制器的默认名称)。

更多相关文章

  1. [CI]CodeIgniter视图 & 模型 & 控制器
  2. laravel 4路由::控制器()方法返回NotFoundHttpException。
  3. ThinkPHP3.2学习——路由_路由定义
  4. 使用jquery / ajax在CodeIgniter控制器内调用函数
  5. thinkphp3.2【空操作和空控制器使用】
  6. 在Yii中获取当前控制器和操作ID
  7. 从模型到控制器并返回到模型的数据
  8. MySQL中间件之ProxySQL(12):禁止多路路由
  9. 将JSON ID键插入到ng-click指令中,然后将其传递到另一个控制器

随机推荐

  1. https://maven.google.com 连接不上的解
  2. Android判断GPS是否开启和强制帮用户打开
  3. Android 对话框
  4. Android中MediaButtonReceiver广播监听器
  5. Android修炼之道—时间测量
  6. php直播源码安卓自定义Dialog设置自动消
  7. Get the Android SDK---获取Android SDK
  8. Delphi XE5 android toast
  9. Android(安卓)判断当前介面是否是在桌面
  10. Android onMeasure、Measure、measureChi