[TYPO3-50-general] Breaking changes in Routing

Bastian Waidelich bastian at typo3.org
Mon Feb 16 17:25:17 CET 2009


Hi everybody,

I've just committed a rework of the FLOW3 routing mechanism.
Most changes affect the internal handling of Routes, but there are some 
"breaking changes". So if you have already created custom routes, you'll 
probably have to update them to the new syntax.
Here are the changes:

1. "dynamic Route Parts are no longer enclosed by square brackets but by 
curly brackets" (see http://forge.typo3.org/issues/show/2342).

So instead of "static/[dynamic]" it must be "static/{dynamic}" from now on.

2. "routes are configured globally" (see 
http://forge.typo3.org/issues/show/2126)

I've moved all routes from Packages/XYZ/Configuration/Routes.yaml to the 
global Routes configuration Configuration/Routes.yaml.
Local Routes will be loaded still, but that's gonna change soon.

3. "support for optional route parts" (see 
http://forge.typo3.org/issues/show/1790)

By putting parts of the URI pattern in round brackets you can mark them 
optional.
E.g. if you have a list of items and a page browser, you might have 
following route setup:

ProductList:
   uriPattern: 'products(/{page}).html'
   defaults:
     page:        '1'

now the request path "products.html" would match and the argument "page" 
would have the default value of "1".
"products/2.html" would match as well and "page" would have the value of 
"2".
When you generate a link using a ViewHelper or Fluid, the result would be:

array()   --> "products.html"
array('page' => '1')   --> "products.html"
array('page' => '2')   --> "products/2.html"

So the optional is only present, if it differs from it's default.
If you want to force the page number to appear in the URI... well, just 
leave away the brackets: "products/{page}.html".

If you're not sure about the syntax, just have a look at the global 
Routes or post your questions here.
I'm working on a Route-Tester that allows you to test your Routes in a 
wizard-like interface.

Documentation will follow soon!

Bastian

-- 
slice up the elephant, baby!


More information about the TYPO3-project-5_0-general mailing list