2

I'd like to change the way URLs that Zend Framework is generating from this:

$routeString = '/section/:sectionName';
$route = new Zend_Controller_Router_Route(routeString, array( etc, etc... );

...to this...

$routeString = '/section_:sectionName';
$route = new Zend_Controller_Router_Route(routeString, array( etc, etc... );

Note that in the second option the middle slash in $routeString is replaced by an underscore.

When I make this change, the router stops recognizing the route and variables. I find it quite strange that the framework would impose such thing so I'm sure I'm missing something in the docs.

Cheers!

akond
  • 15,865
  • 4
  • 35
  • 55
Julian
  • 8,808
  • 8
  • 51
  • 90

1 Answers1

4

I think you could do it using Zend_Controller_Router_Route_Regex. As an example I'll provide setup for your route in the application.ini:

resources.router.routes.section.type = "Zend_Controller_Router_Route_Regex" 
resources.router.routes.section.route = "section_(\d+)"
resources.router.routes.section.defaults.module = yourmodule
resources.router.routes.section.defaults.controller = yourcontroller
resources.router.routes.section.defaults.action = youraction
resources.router.routes.section.map.1 = "sectionName"
resources.router.routes.section.reverse = "section/%d"

Hope this will help you or at least point you in the right direction.

Marcin
  • 215,873
  • 14
  • 235
  • 294