[TYPO3-team-core-v5] TYPO3 v5 Routing

Bastian Waidelich waidelich at network-publishing.de
Thu Jun 19 09:53:47 CEST 2008


Peter Niederlag wrote:

Hello Peter,

>>     $route = new Zend_Controller_Router_Route(
>>         'news/:id',
>>         array(
>>             'module' => 'default',
>>             'controller' => 'news',
>>             'action'     => 'show'
>>         )
>>     );
>>     $router->addRoute('news', $route);


> Is the leading ':' in the second example on the first
> constructor-argument ('new/:id') left out by purpose?

Yes. The example is taken from the Zend Framework routing (which works 
similar to a lot of other frameworks and cms):
An URL segment with a colon makes this part dynamic. So in this case: 
the value that comes after "news/" will be stored to the variable "id".
"news" is static. So this route only matches if the first url segment is 
equal to "news".
In our concept we're using brackets "[]" rather than colons because
1. I think, they're more coherent
2. we might need something like "news/[newsTitle].html" or 
"news/list.[format]" once.


> Does the first argument on the ->addRoute function have any special
> maaning?

Yes. The first argument is the name of this route. In ZF routes have 
unique names. You can refer to this name when creating links in 
templates (URL helper). This is faster than going through all existing 
routes and check whether the specified values match.
We're going to cache routes and links in FLOW3, so we probably won't 
need this.

thx,
Bastian


More information about the TYPO3-team-core-v5 mailing list