adding a Route to the a Router in Zend Framework

后端 未结 4 1830
隐瞒了意图╮
隐瞒了意图╮ 2021-02-11 11:06

I am using the mod-rewrite router.

I am trying to add a Route to the router that will convert the following url:
baseurl/category/aaa/mycontroller/myaction/param/v

相关标签:
4条回答
  • 2021-02-11 11:26

    Please check http://webhkp.wordpress.com/2012/01/01/zend-framework-custom-router/ this would solve your porblem.

    its done with an ini file. i like to do it this way

    0 讨论(0)
  • 2021-02-11 11:26

    You have to specify the defaults when creating the route (see dcaunt's post) OR specify all of the parameters in url view helper (category, controler and action)

    0 讨论(0)
  • 2021-02-11 11:40
    $Router=$this->_front->getRouter();
    $CategoryRoute = new Zend_Controller_Router_Route('category/:category/:controller/:action/*');
    $Router->addRoute('category', $CategoryRoute);
    

    Try adding a start to specify the existence of extra params

    0 讨论(0)
  • 2021-02-11 11:44

    You should include the /* as suggested by solomongaby.

    If not supplying all of the required parameters (i.e. category, controller and action), you will need to specify defaults.

    You can do so as follows:

    $Router=$this->_front->getRouter();
    
    $CategoryRoute = new Zend_Controller_Router_Route('category/:category/:controller/:action/*',
        array(
            'controller' => 'index',
            'action'     => 'index',
            'category'   => null
        )
    );
    $Router->addRoute('category', $CategoryRoute);
    
    0 讨论(0)
提交回复
热议问题