omnitroy Posted June 30, 2012 Share Posted June 30, 2012 When I install a module, usually, I can only config it by clicking the module tab and search for that specific module, and then "configure" it. Question is: is it possible that we can hook that configure part to becoming a tab in the back-end? For example, minic slider module. What if I want to just click a tab in the admin panel to access it? Link to comment Share on other sites More sharing options...
bellini13 Posted July 1, 2012 Share Posted July 1, 2012 The only approach I am aware of is to include an AdminModuleTab class with your module, that implements your configuration. So instead of implementing your configuration from within the module, you simply redirect to the AdminModuleTab, like below. public function getContent() { global $cookie; $tab = 'AdminModuleMenu'; $token = Tools::getAdminToken($tab.(int)(Tab::getIdFromClassName($tab)).(int)($cookie->id_employee)); Tools::redirectAdmin('index.php?tab=' . $tab . '&token=' . $token); } Link to comment Share on other sites More sharing options...
omnitroy Posted July 1, 2012 Author Share Posted July 1, 2012 WOW. Great! Thanks a lot, Mike. I think I will make some research and test now. Link to comment Share on other sites More sharing options...
omnitroy Posted July 5, 2012 Author Share Posted July 5, 2012 The only approach I am aware of is to include an AdminModuleTab class with your module, that implements your configuration. So instead of implementing your configuration from within the module, you simply redirect to the AdminModuleTab, like below. public function getContent() { global $cookie; $tab = 'AdminModuleMenu'; $token = Tools::getAdminToken($tab.(int)(Tab::getIdFromClassName($tab)).(int)($cookie->id_employee)); Tools::redirectAdmin('index.php?tab=' . $tab . '&token=' . $token); } I built a tag in admin HOME, called "Slide" and class name "AdminSlide". And I changed the getContent function within slideric module and it redirects to Slide Tag ---- but it is only when I click the Module tag and reach the slideric module and configuring it, it redirects to the slider Tag. In fact, what I really want is that when I click the Slide Tag, it redirects to the configuration of the slideric module. Link to comment Share on other sites More sharing options...
bellini13 Posted July 6, 2012 Share Posted July 6, 2012 then you just need to do the opposite of what I stated. implement the configuration in the module, and then redirect to the modules configuration page from the AdminSlide class Link to comment Share on other sites More sharing options...
kerrr Posted July 6, 2012 Share Posted July 6, 2012 WOW.it is great . Link to comment Share on other sites More sharing options...
innercode Posted July 20, 2012 Share Posted July 20, 2012 Hello, I'm searching how to do similarly to this but a little bit different. We are modifying PrestaShop tabs' access for different roles and I need to make a slider configuration from a tab / sub-tab, e.g. under Tools tab. Redirecting to module is not a solution because modules can't be accessed from that specific role. Is there any solution how to achieve this? Thanks Link to comment Share on other sites More sharing options...
omnitroy Posted July 20, 2012 Author Share Posted July 20, 2012 In fact, I still do not succeed in making a tab in the back-end that accessing a module. But I am beating it around: I use Quick Access to point to the URL of an module configuring. So. Link to comment Share on other sites More sharing options...
Knight4 Posted November 14, 2012 Share Posted November 14, 2012 In fact, I still do not succeed in making a tab in the back-end that accessing a module. But I am beating it around: I use Quick Access to point to the URL of an module configuring. So. I was trying to do this but somehow I keep getting invalid security tokens... Any ideas? Cheers Link to comment Share on other sites More sharing options...
Rohit Singhal Posted January 20, 2013 Share Posted January 20, 2013 @bellini13, will this work for v1.5? The only approach I am aware of is to include an AdminModuleTab class with your module, that implements your configuration. So instead of implementing your configuration from within the module, you simply redirect to the AdminModuleTab, like below. public function getContent() { global $cookie; $tab = 'AdminModuleMenu'; $token = Tools::getAdminToken($tab.(int)(Tab::getIdFromClassName($tab)).(int)($cookie->id_employee)); Tools::redirectAdmin('index.php?tab=' . $tab . '&token=' . $token); } Link to comment Share on other sites More sharing options...
edmondas Posted May 30, 2013 Share Posted May 30, 2013 The only approach I am aware of is to include an AdminModuleTab class with your module, that implements your configuration. So instead of implementing your configuration from within the module, you simply redirect to the AdminModuleTab, like below. public function getContent() { global $cookie; $tab = 'AdminModuleMenu'; $token = Tools::getAdminToken($tab.(int)(Tab::getIdFromClassName($tab)).(int)($cookie->id_employee)); Tools::redirectAdmin('index.php?tab=' . $tab . '&token=' . $token); } It's not clear why you add employee cookie to the end of token, it should work without that (tested on PS 1.5) public function initContent() { $tab = 'AdminModules'; $configure=$module_name='blockcart'; $tab_module='front_office_features'; $token = Tools::getAdminTokenLite($tab); Tools::redirectAdmin('index.php?tab=' . $tab . '&token=' . $token . '&configure='.$configure.'&tab_module='.$tab_module.'&module_name='.$module_name); } Link to comment Share on other sites More sharing options...
bellini13 Posted May 30, 2013 Share Posted May 30, 2013 It's not clear why you add employee cookie to the end of token, it should work without that (tested on PS 1.5) public function initContent() { $tab = 'AdminModules'; $configure=$module_name='blockcart'; $tab_module='front_office_features'; $token = Tools::getAdminTokenLite($tab); Tools::redirectAdmin('index.php?tab=' . $tab . '&token=' . $token . '&configure='.$configure.'&tab_module='.$tab_module.'&module_name='.$module_name); } If you look at the AdminTab class, you will see that is how Prestashop creates the token. $this->token = Tools::getAdminToken($className.(int)$this->id (int)$this->context->employee->id); Link to comment Share on other sites More sharing options...
edmondas Posted June 3, 2013 Share Posted June 3, 2013 If you look at the AdminTab class, you will see that is how Prestashop creates the token. $this->token = Tools::getAdminToken($className.(int)$this->id (int)$this->context->employee->id); getAdminTokenLite() is simplified version of getAdminToken() (does practically the same), source code excerpt from ToolsCore class (Tools.php file): public static function getAdminToken($string) { return !empty($string) ? Tools::encrypt($string) : false; } public static function getAdminTokenLite($tab, Context $context = null) { if (!$context) $context = Context::getContext(); return Tools::getAdminToken($tab.(int)Tab::getIdFromClassName($tab).(int)$context->employee->id); } Link to comment Share on other sites More sharing options...
bellini13 Posted June 5, 2013 Share Posted June 5, 2013 either way, the answer is that the string that gets encrypted should contain the employee id. 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