Friday, May 6, 2011

Zend Route Regex Reverse problem with forward slashes

Hi I have a problem with reverse for regex routes, my config file is below:

routes.route1.type = "Zend_Controller_Router_Route_Regex"
routes.route1.route = "([^\,]+)([^p]*)(?:\,page_[0-9]+)?\.html"
routes.route1.defaults.controller = "index"
routes.route1.defaults.action = "find"
routes.route1.map.1 = "url_path"
routes.route1.map.2 = "url"
routes.route1.map.3 = "options"
routes.route1.map.4 = "page"
routes.route1.reverse = "%s%s,page_%d.html"

the url will be http://www.site.com/cat1/cat2/cat3/cat4/cat5/title-id1_id2,page_1.html the number of categories is unspecified current regex works fine, and gets all the categories at once, but the reverse formats all forward slashes to html format: %2F does anyone know how I can keep the forward slashes? I need the reverse for pagination and all the html entities look just plain ugly.

thx :)

From stackoverflow
  • If you're using the URL helper, set the fourth parameter to false to disable the encoding (which is on by default). So something like:

    <?=$this->url(array(
       'url_path' => 'whatever',
       'url' => 'something'
       'options' => 'foo',
       'page' => 'bar'
    ), 'route1', false, false)?>
    

0 comments:

Post a Comment