adding a Route to the a Router in Zend Framework

时光总嘲笑我的痴心妄想 提交于 2019-12-03 09:15:54

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);
$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

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

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)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!