R
R
Roman Ivashkevich2013-10-19 04:51:12
Zend Framework
Roman Ivashkevich, 2013-10-19 04:51:12

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 - выводит написанный блог

I googled for a couple of hours, I did not find adequate and explaining information. I've been working with Zend for quite some time now, so I've stalled.
Thanks for any help provided :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
cawakharkov, 2013-10-29
@cawakharkov

Yes, it is possible to implement this using regular expressions, but there are differences in the implementation of zf1 and zf2 routing

M
Morfij_E, 2013-11-14
@Morfij_E

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 question

Ask a Question

731 491 924 answers to any question