tdog4224
tdog4224

Reputation: 150

How to use optional parameters at zend routing

I want to set a similar routing to the standard-router with optional parameters, e.g.:

intranet.route = 'intranet/:controller/:action/:title/:id'

only the id-parameter doesn't need a value. i tried giving it an default value like null - but then the variable is still set, but i don't want it to exist at all when the user does not give it any value

also, how can i set up a route with dynamic values, just like this:

intranet/index/index/Front%20Page/123/foo/bar

then the variable $foo exists with the value "bar"

Upvotes: 1

Views: 3065

Answers (1)

Ibrahim Azhar Armar
Ibrahim Azhar Armar

Reputation: 25753

you can set a default value to a parameter in application.ini like

resources.router.routes.intranet.defaults.id = null

or if you want to set a dynamic route you can use *

intranet.route = 'intranet/:controller/:action/:title/*

this makes the variable after title optional.

Upvotes: 5

Related Questions