danielmoreira Posted September 7, 2015 Share Posted September 7, 2015 Hi, I am developing a module for prestashop. I would like my module to redirect to a admin controller i created once i install the module. By default, if a module has a configuration page generated by the getContent method, it will redirect to this page when the module installed. I want my module to redirect to a different page. Does anyone know how to do this? Thanks for your attention Link to comment Share on other sites More sharing options...
danielmoreira Posted September 7, 2015 Author Share Posted September 7, 2015 This is exactly what i was looking for. Thanks a lot! Problem solved Link to comment Share on other sites More sharing options...
kimokimo Posted January 20, 2020 Share Posted January 20, 2020 can you share the solution with us please ? Link to comment Share on other sites More sharing options...
SmartPlugs Posted January 20, 2020 Share Posted January 20, 2020 (edited) I do that in one of mines. I first declare and leave empty the getContent() method (module main file) : public function getContent() {} This will force PrestaShop to display the "configure" button. Then i plug the module on the "actionDispatcher" hook and add the following code (example) in the hookActionDispatcher() méthod : public function hookActionDispatcher($args) { if (defined('_PS_ADMIN_DIR_')) { if (isset($args['controller_class']) && $args['controller_class'] == 'AdminModulesController') { if (Tools::getValue('configure') == '_your_module_name_') { $link = new Link(); Tools::redirectAdmin($link->getAdminLink('_your_controller_tab_name_')); } } } } Edited January 20, 2020 by SmartPlugs (see edit history) Link to comment Share on other sites More sharing options...
kimokimo Posted January 20, 2020 Share Posted January 20, 2020 33 minutes ago, SmartPlugs said: I do that in one of mines. I first declare and leave empty the getContent() method (module main file) : public function getContent() {} This will force PrestaShop to display the "configure" button. Then i plug the module on the "actionDispatcher" hook and add the following code (example) in the hookActionDispatcher() méthod : public function hookActionDispatcher($args) { if (defined('_PS_ADMIN_DIR_')) { if (isset($args['controller_class']) && $args['controller_class'] == 'AdminModulesController') { if (Tools::getValue('configure') == '_your_module_name_') { $link = new Link(); Tools::redirectAdmin($link->getAdminLink('_your_controller_tab_name_')); } } } } what if i want to redirect to a diffrant link outside prestashop after the installation of the module directly ? Link to comment Share on other sites More sharing options...
SmartPlugs Posted January 20, 2020 Share Posted January 20, 2020 Hi kimokimo, If you have a look on the code i posted i'm sure you gonna find the line that does the redirect, please. But i'm not sure PrestaShop, addons i mean if your goal is to sell your module on addons, would let you redirect people to another location after module install... Yann Link to comment Share on other sites More sharing options...
kimokimo Posted January 21, 2020 Share Posted January 21, 2020 (edited) 17 hours ago, SmartPlugs said: Hi kimokimo, If you have a look on the code i posted i'm sure you gonna find the line that does the redirect, please. But i'm not sure PrestaShop, addons i mean if your goal is to sell your module on addons, would let you redirect people to another location after module install... Yann hi Yann, actually i have tried but it didn't work, i have tried doing this code return (parent::install() && this.hookActionDispatcher() ); } public function getContent() {} public function hookActionDispatcher() { $link = new Link(); Tools::redirect('https://mywebsite.com'); } but it didn't work unfortunatly, could you help ? i also tried this code to redirect return (parent::install() && this.header('location: http://www.mysite.com/index.php?pop=yes') ); still no chance Edited January 21, 2020 by kimokimo missing informations (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted December 3, 2023 Share Posted December 3, 2023 No hook need^^ public function getContent() { Tools::redirectAdmin($this->context->link->getAdminLink('_your_controller_tab_name_')); } 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