Norbert Orzechowicz
Norbert Orzechowicz

Reputation: 1311

Zend Router Configuration

I'm wondering if its even possible to use slashes in variables that are defined in Zend Router.

For example I have something like this

modules/ modules/default/ modules/default/controllers/ modules/default/controllers/OfferController.php

In OfferController.php I have action showAction()

And I have few offers in database that have unique url for example

id | unique url

1 | /url-1/

2 | /url-2/

3 | /url-2/still-url-2/

What I need is to search offers in showAction by url parameter that will be passed from link

Example of urls that i want to use:

http://example.com/offer/url-1/ - this will search offer with id 1

http://example.com/offer/url-2/still-url-2/- this will search offer with id 3

So its possible to configure Zend Router for my purpose?

Upvotes: 0

Views: 440

Answers (1)

drvdijk
drvdijk

Reputation: 5554

The quick answer would be to say the URL should read: http://example.com/offer/url-2%2fstill-url-2/-

Also, from the manual about Zend_Controller_Route_Route is says:

Note: Character Usage The current implementation allows you to use any character (except a slash) as a variable identifier, but it is strongly recommended that one uses only characters that are valid for PHP variable identifiers. Future implementations may alter this behaviour, which could result in hidden bugs in your code.

But maybe you could have a look at the Zend_Controller_Router_Route_Regex

Upvotes: 1

Related Questions