Strange problem with pretty urls in module
Posted: Tue Apr 09, 2013 9:18 am
Hi, I'm working on module, which purpose is manage recipes. I want to use pretty url's of course. For showing detail of recipe I want to use the url looks like "/recipe/the-title-of-recipe". My question is how to achieve this kind of url in my module? I'm research the knowledge of that in News module, and I saw that:
So I decided do it in my module like that:
It works fine, and for getting url like this:
I'm using this code
I think, this is very similar with method used in News module, but not works properly.
When I open this url it shows only this action content without template, but news module shows action content with template.
What is wrong?
Code: Select all
$route = new CmsRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/(?P<junk>.*?)\/d,(?P<detailtemplate>.*?)$/',
$this->GetName());
cms_route_manager::add_static($route);
Code: Select all
$route = new CmsRoute('/recipe\/(?P<recipeurl>.*?)\/(?P<returnid>[0-9]+)$/', $this->GetName());
cms_route_manager::add_static($route);
Code: Select all
/recipe/the-title-of-recipe/57
Code: Select all
$this->CreateLink($id, 'recipe_view', $returnid, '', array('recipe_id' => $recipe['id']), '', true, false, '', true, 'recipe/'.$recipe['url'].'/'.$returnid);
When I open this url it shows only this action content without template, but news module shows action content with template.
What is wrong?