Page 1 of 1

Module and PrettyURL

Posted: Fri Feb 04, 2011 2:08 pm
by leif
I maintain a website for a university department:
http://www.control.lth.se
It is powered by cmsms 1.9.2, and most things work as I expect them to, including prettyURLs in general. There is however a specific problem when I want to use prettyURLs in a module I have written. The module is for displaying information from our publication database, and the RegisterRoute statement in the module.php file is

Code: Select all

  $this->RegisterRoute('#Publication/(?P<artkey>.+$)#',
                       array('action'=>'showpublication','returnid'=>'60'));
This works in many cases, for example (ugly URL followed by prettyURL):
http://www.control.lth.se/index.php?mac ... eturnid=60
http://www.control.lth.se/Publication/gis10cdc.html
However, in the following case the prettyURL fails:
http://www.control.lth.se/index.php?mac ... eturnid=60
http://www.control.lth.se/Publication/hen+cer10.html
The reason it fails is the '+' character in the last part of the URL. I have found out that when it comes in to the action routine, as the variable $artkey, its value is 'hen cer10' instead of 'hen+cer10'. It does not help to use '%2B' in the URL, it is still converted to a space character.

After all this introduction on to my question: Is there some specification that says that this is the required behavior, or is there some other reason? I have tried to find it in the source, but I don't know my way around well enough. In this particular case I can work around the problem by simply letting the action routine convert space to '+', but it is not a very satisfying solution.

Thanks,
Leif

Re: Module and PrettyURL

Posted: Tue Jun 28, 2011 5:11 pm
by mmarius
Hi,

Try using {metadata} inside the header of the template and test this route: '[pP]ublication/(?P<artkey>.+)$/'

Marius.