Module and PrettyURL

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
leif
New Member
New Member
Posts: 4
Joined: Tue Oct 19, 2010 8:14 pm

Module and PrettyURL

Post 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
mmarius
New Member
New Member
Posts: 3
Joined: Tue Jun 28, 2011 4:43 pm

Re: Module and PrettyURL

Post by mmarius »

Hi,

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

Marius.
Post Reply

Return to “Developers Discussion”