drza10046 2014-07-08 11:16
浏览 30

Zend Framework 2使用带有可选参数的导航use_route_match选项

I am having problems on using the use_route_match feature, i want to see only some of the params instead of all in the generated url, is it possible to setup a conf as i tried to do below? Or What do you suggest?

My global.php

return array(
    'navigation'      => array(
    'default'    => array(
            array(  
                'route'           => 'home',
                'label'           => 'Anasayfa',
                'resource'        => 'Application\Controller\Index\index',
                'use_route_match' => true
            )
        )
    )
);

how can i use "use_route_match" only my optional params ?

for example

return array(
    'navigation'      => array(
    'default'    => array(
            array(  
                'route'                    => 'home',
                'label'                    => 'Anasayfa',
                'resource'                 => 'Application\Controller\Index\index',
                'use_route_match'          => true,
                'use_route_match_myparams' => array('lang', 'param1', 'param2')
            )
        )
    )
);
  • 写回答

1条回答 默认 最新

  • dqd22496 2014-07-09 09:43
    关注

    you have route like this

    'home' => array(
        'type'    => 'Literal',
        'options' => array(
            'route'    => '/home[/:lang][/:param1][/:param2]',
            'constraints' => array(
              'id' => '[0-9]+',
            ),
            'defaults' => array(
                'controller' => 'Application\Controller\Index',
                'action'     => 'index',
            ),
         ),
     ),
    

    and your navigation

    return array(
        'navigation'      => array(
        'default'    => array(
                array(  
                    'route'                    => 'home',
                    'label'                    => 'Anasayfa',
                    'resource'                 => 'Application\Controller\Index\index',
                    'use_route_match'          => true,
                    'params' => array('lang' => 'en', 'param1' => 'param1')
                )
            )
        )
    );
    

    there is no param2 here

    评论

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭