3ehrang
3ehrang

Reputation: 629

url routing in zend framework

Hi I created several module for my own CMS like category, article, core , ...
now how can I access these modules with url like:

http://localhost/mycms/admin/category
http://localhost/mycms/admin/article , ...

note: the admin is not module, it's only prefix

Upvotes: 1

Views: 2057

Answers (1)

Nấm Lùn
Nấm Lùn

Reputation: 1275

In "application/Bootstrap.php":

public function _initRoute(){    

$frontController = Zend_Controller_Front::getInstance();

            $router = $frontController->getRouter(); // returns a rewrite router by default
            $router->addRoute(
                'category',
                new Zend_Controller_Router_Route('admin/category/:controller/:action',
                                                 array('module' => 'category',
                                                        'controller' => 'index',
                                                       'action' => 'index'))
            );
}

Then type in URL : ex : http://localhost/mycms/admin/category and you get there.

Same with others.

Upvotes: 2

Related Questions