views:

20

answers:

1

I need a Zend_Controller_Route_Route with controller => 'downloads', action => 'index' and a parameter variable which is infinite.

www.domain.com/downloads/this/is/the/path/to/the/folder 

should redirect to

DownloadsController > indexAction

I was thinking about something like the following:

'downloads' => array(
        'route' => 'downloads/*',
        'defaults' => array('controller' => 'downloads', 'action' => 'index')

But how do I request the * as a parameter?

+1  A: 

You can use a RegEx Route http://framework.zend.com/manual/de/zend.controller.router.html#zend.controller.router.routes.regex

$router = Zend_Controller_Front::getInstance()->getRouter(); // returns a rewrite router by default

$route['default'] = new Zend_Controller_Router_Route_Regex(
    '/downloads/(.*)',
    array(
        'controller'=> 'Downloads',
        'action'    => 'index',
    ),
    array(
        1           => 'downloadpath',
    )
);

$router->addRoute('default', $route['default']);

I havent tested it but something like that shoudl work

Hannes
@Hannes +1 Thanks! This is exactly what I was looking for!
yens resmann
@yens resmann You're welcome, maybe that'll also help you http://www.lautr.com/modifying-the-zend-framework-router-an-example-for-a-simple-website wrote it a while back about that subject
Hannes