28/10 2012
Automatic Realurl Rules

URL Mojo going up.

UPDATE: for a short while the feature will require the most recent Git master of Realurl as well. If this Realurl patch is still not merged when you read this you also need to apply that before you can use the most recent iteration of FED's Realurl feature.

Dear developers,

Last night I finished the first iteration of a FED feature that I want to tell you a little about. There have been so many times where I wished that my Extbase extensions could have Realurl rules created for them automatically - and I finally solved this.

Using a hook in Realurl and some processing of the current content elements, FED can now make automatic Realurl rules for all installed Extbase plugins which use arguments (since arguments are what makes sense to Realurl) and only for the topmost plugin on the page currently - in order to avoid rule colissions. SwitchableControllerActions are supported and using a Domain Object as an argument for your controller action (i.e. your showAction) a rule is added to perform lookup in the table used by that Domain Object.

This means that extensions like EXT:news are automatically set up with a basic URL rewriting for things like detail views. With no need whatsoever to use a custom Realurl configuration. Since all content elements are scanned the rules are automatically added for every page which has - for example - an EXT:news detail view. The rules are rebuilt when the realurl_autoconf.php file is removed (and a hook will be used to take care of that when "all caches" are cleared).

The feature can be enabled simply by enabling the extension configuration switch (it's located where all the other switches for features are located; in the EM's extension config panel for EXT:fed) and is currently merged in the Github master if you want to have a go at it: 

github.com/NamelessCoder/fed

. You can also read the commit message explaining some of the technical details: 

github.com/NamelessCoder/fed/commit/b7eb6dc24770e0f679bc25c0968fee89ec4baf2d

.

My hope is that this makes your life a whole lot more easier by making your extension's URLs prettier - and by automatically recognising changes such as a new page that requires rules.

Future plans include the use of class and method annotations to define in detail how FED should process each Controller and action when this feature is enabled. Using class annotations is comfortable enough for this tiny configuration purpose - and they are of course completely non-destructive and silently ignored by everything that doesn't use them.

I would be happy to hear your suggestions and ideas. I am after all building this for all of us, not just me ;)

Cheers,
Claus