0

After creating a modular structure for a single module would prevent the url appears the name of the controller.

everything works with the defaul

site.con/foo/index/action/

I wish I could write as

site.com/foo/action/

being IndexController the only controller that module.

I have tested several solutions but do not work. Being the first app with ZF I do not quite clear the steps to be taken.

inge
  • 15
  • 3

1 Answers1

2

You need Zend Routes.

Define routes in your

bootstrap.php

Open your bootstrap.php and put the following:

function _initRoutes() {
        $front_controller = Zend_Controller_Front::getInstance();
        $router = $front_controller->getRouter();
        $router->addRoute('foo-action', new Zend_Controller_Router_Route(
            '<foo module name>/<action name>', array('module' => 'foo', 'controller' => 'index', 'action' => '<action-name>')
        ));
}

PS:Worked / Didn't work? Mention in comments and if didn't work, give proper names of module, controller and action.

EDIT:

How to set default controller / module in application.ini

routes.index.type = "Zend_Controller_Router_Route"
routes.index.route = "/"
routes.index.defaults.module = "<module name>"
routes.index.defaults.controller = "index"
routes.index.defaults.action = "index"

Solves it?

Keval Domadia
  • 4,768
  • 1
  • 37
  • 64
  • You can get the same result from the file Application.ini? I'm looking for a solution that works equally for all controller actions – inge Aug 16 '12 at 12:12
  • Yes, thank you! Could you explain the meaning of each command? – inge Aug 17 '12 at 05:59
  • `routes.index.type` - will ask what type of routes are we calling. `routes.index.route` - will ask what is the scope of routes (in our case entire application so it is root folder or "/" `routes.index.defaults.module` - what module you want to put as default. in our case foo. `routes.index.defaults.controller` - controller which will be default (by default it is index only) `routes.index.defaults.action` - action which will be default (by default it is index). If it answered your question, please click on "tick" which is on left hand side of my answer so that others can refer to it. – Keval Domadia Aug 17 '12 at 06:04