Jump to content

Module routes

Denis Gerasimov

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?

Link to comment
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.





Hope this is what you were looking for,



Link to comment
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:


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


  • Like 2
Link to comment
Share on other sites

  • 5 years later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...