Denis Gerasimov Posted July 6, 2014 Share Posted July 6, 2014 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 More sharing options...
PascalVG Posted July 6, 2014 Share Posted July 6, 2014 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, pascal Link to comment Share on other sites More sharing options...
Denis Gerasimov Posted July 7, 2014 Author Share Posted July 7, 2014 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". 2 Link to comment Share on other sites More sharing options...
pawelszulc Posted October 24, 2019 Share Posted October 24, 2019 Hi @Denis Gerasimov please tell me, param id is required? can I enter a link without a parameter? Link to comment Share on other sites More sharing options...
cjordan Posted November 28, 2019 Share Posted November 28, 2019 Hello, any way of doing this in prestashop 1.7.6.1? The Documentation is not clear Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now