-- Nick Pack <[email protected]> wrote
(on Wednesday, 08 September 2010, 04:15 PM +0100):
> I have a route defined for a url shortener project I am working on, which
> partially works, but I cant get to the bottom of something, route is defined 
> as
> follows:
> 
> resources.router.routes.shortRoute.type = "Zend_Controller_Router_Route"
> resources.router.routes.shortRoute.route = ":shortpart"
> resources.router.routes.shortRoute.defaults.action = "index"
> resources.router.routes.shortRoute.defaults.controller = "index"
> 
> If :shortpart is numeric, the route behaves as expected, and dispatches the
> indexAction of IndexController with it as a request parameter, however if 
> there
> is a letter for :shortpart it throws an exception about the controller not
> being defined.
> 
> Is there a way I can override this behaviour so that it always dispatches to
> the correct action?

I just created a new project, and added the routes as you've defined
them above, and everything worked exactly as expected. 

In my IndexController, indexAction() was defined as thus:

    $this->view->route = $this->_getParam('shortpart', '__empty__');

and I created a view that simply did this:

    <h2>Requested: <?php echo $this->route ?></h2>

It worked for anything I pushed into the URL.

My guess is you have other routes that are conflicting with the one
you've detailed. Can you provide your full routes configuration?

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Reply via email to