bonez
bonez

Reputation: 695

Using a dash (-) instead of a plus (+) in Zend Framework URLs

by default it seems my ZF is separating multiple parameter words with plus signs.

eg. /product/test+product+name

I would like to use -> /product/test-product-name

Here is the line from routes.ini

routes.product.route = "product/:productName"<br />
routes.product.defaults.controller = product<br />
routes.product.defaults.action = product 

What can do I do to fix this?

Upvotes: 0

Views: 716

Answers (2)

David Snabel-Caunt
David Snabel-Caunt

Reputation: 58371

This happens because the URLs are urlencoded to ensure document validity. You'll need to filter/replace the terms (productName) before generating routes. A simple str_replace should be all that you need. In my app, I filter excess whitespace and then replace spaces with dashes.

Upvotes: 1

Tyler Carter
Tyler Carter

Reputation: 61577

Well, as the + sign is commonly known to browsers to separate words, I don't thing Zend has provided an option, an most likely just uses +s because it is correct.

You might have to edit the source.

You may want to look at the Regex Routing here. It seems like it might be useful.

Upvotes: 0

Related Questions