views:

150

answers:

1

Ive got a url: http://dev.local/foodies/view?id=bluedaniel

and ive got in my bootstrap:

protected function _initRoute() {
        $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
        $router = new Zend_Controller_Router_Rewrite();
        $router->addConfig($config, 'resources');
    }

and ive also got in my routes.ini:

[production]
resources.router.routes.foodies_view.route = ":foodies/:id"
resources.router.routes.foodies_view.defaults.module = "foodies"
resources.router.routes.foodies_view.defaults.controller = "view"
resources.router.routes.foodies_view.defaults.action = "index"

so http://dev.local/foodies/bluedaniel should work right?

I get a Resource 'foodies:bluedaniel' not found error however with this setup

--------------- UPDATE ----------------

Instead of the above I added the following to the application.ini file:

resources.router.routes.myroute.route = "foodies/:id"
resources.router.routes.myroute.defaults.module = "foodies"
resources.router.routes.myroute.defaults.controller = "view"
resources.router.routes.myroute.defaults.action = "index"
resources.router.routes.myroute.defaults.id = "\w+"

This method now works although I would still prefer the routes in their seperate ini file if I can help it.

A: 

If anyone is interested, I have solved the problem, now in my bootstrap:

protected function _initRoutes() {
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $router->addRoute('userprofile', new Zend_Controller_Router_Route('user/:id/', array('module' => 'foodies', 'controller' => 'view', 'action' => 'index', 'id'=>'\w+')));
}

The problem was that in my navigation.xml I needed to add <route>default</route> to every node. Zend documentation can be very very poor indeed at times.

I also needed to declare a default variable for id otherwise it wouldnt recognise it being passed.

bluedaniel
and then in the view helper $this->url(array('module'=>'foodies', 'controller'=>'view'), 'userprofile'); to create the url in the desired format.
bluedaniel