Jump to content

Recommended Posts

According to this Prestashop blog article, there is a way i can get pretty module urls like "http://www.yourstore.com/module/mymodule/orders/details/42".

I found next line in Dispatcher "loadRoutes" method, which i assume is responsible for getting such result:

$modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false);

But i can't find neither documentation on "moduleRoutes" hook, nor any examples of it's usage. Also there is no mention of "moduleRoutes" hook on Prestashop hooks documentation page. Googling on "prestashop custom routes" got nothing.

 

So the question is how do i get pretty module urls as they were described in above-mentioned article?

Share this post


Link to post
Share on other sites

Hi Denis,

The URL's you can adjust in Back Office: Preferences->SEO & URLs (scroll down to see the current "Schema of URLs".

 

Here you can change the URL build-up, using the keywords given below each of the fields. Additional characters can be used as desired to separate or decorate the URL parts.

 

post-455771-0-59052400-1404685930_thumb.png

 

 

Hope this is what you were looking for,

pascal

 

Share this post


Link to post
Share on other sites

Hello, Pascal. It's not exactly what i need.

 

I need additional keywords for specific module (for now i have only common "module" and "controller" keywods).

 

But i finally made it work.

All i need to do was to add a new row in ps_hook table with name "moduleRoutes". Then in my module write:

public function hookModuleRoutes($params)
{
return [
'module-mymodule-display' => [
'controller' => 'display',
'rule' => 'mymodule{/:id}',
'keywords' => [
'id' => ['regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'id']
],
'params' => [
'fc' => 'module',
'module' => 'mymodule'
]
]
];
}

And in "install" method:

$this->registerHook('moduleRoutes')

That's it. Now i can access mymodule display controller with id param equals 42 by "mymodule/42".

 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More