Need Help in zend framework URL Rewrite

孤者浪人 提交于 2019-12-06 07:59:36

To make it work you need to define a custom route, called e.g. guestbook, and make url helper to use it for your particular url.

For example, in your application.ini you can define it as follows:

resources.router.routes.guestbook.route = '/guestbook/edit/:id'
resources.router.routes.guestbook.defaults.controller = user
resources.router.routes.guestbook.defaults.action = edit
resources.router.routes.guestbook.defaults.id = 
resources.router.routes.guestbook.reqs.id = "\d+" 

Then, you use the url helper in the following way:

echo $this->url(array('controller'=>'user','action'=>'edit','id'=>2), 'guestbook', TRUE);

Hope that helps.

Zend Controller Router will help you achive this .

The easyest way to get started would be at bootstrap add the following ( not realy tested but it should work with minimal debuging, see the link provided as it explains a ton more, use this code just to get started on understanding how routes work ) :

$router = Zend_Controller_Front::getInstance()->getRouter();
$router->addRoute(
    'guestbook_edit',
    new Zend_Controller_Router_Route('guestbook/edit/:id',
                                     array('controller' => 'guestbook',
                                           'action' => 'edit'))
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!