Skip to end of metadata
Go to start of metadata

5.4. Variable defaults

Every variable in the route can have a default. To provide it you have to add a third parameter to the addRoute method. This third parameter is an array with keys as variable names and values as desired defaults.

What may not be clearly visible is that the above route will match URLs like 'http://example.com/archive/2005' and 'http://example.com/archive'. In the latter case the variable year will have a value of 2006.

In the above example we haven't set a controller so it will always result in a noRoute action of an IndexController. To make it usable you have to provide a valid controller and a valid action as a default:

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.