Answer the question
In order to leave comments, you need to log in
Routing in Zend'e?
Good day.
Tell me, knowledgeable people, is it possible (and, if so, how?) To organize routing of this kind in Zend'e:
http://example.com/blogs/ - выводит список разделов блога
http://example.com/blogs/id08 - выводит список блогов соответствующего раздела
http://example.com/blogs/post08 - выводит написанный блог
Answer the question
In order to leave comments, you need to log in
Yes, it is possible to implement this using regular expressions, but there are differences in the implementation of zf1 and zf2 routing
And you can also do this: 1. Initiate the router in Bootstrap:
protected function _initRouter()
{
$fc = Zend_Controller_Front::getInstance();
$router = $fc->getRouter();
$routerConfig = new Zend_Config_Ini('/../applications/configs/routes.ini');
$router->addConfig($routerConfig, 'routes');
}
2. In routes.ini we register a dynamic router:
routes.blog.type = "Zend_Controller_Router_Route"
routes.buy.route = "blog/:id"
routes.blog.defaults.module = "default"
routes.blog.defaults.controller = "blog"
routes.blog.defaults.action = "index"
3. We accept in the corresponding controller 'id'
:
$this->getRequest->getParam('id')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question