PhpMadman Posted September 9, 2014 Share Posted September 9, 2014 In my module I added /controllers/admin/AdminRenderPdf.php And then I added this. <?php class AdminRenderPdf extends ModuleAdminController { public function __construct() { parent::__construct(); } } ?> But PrestaShop refuses to find it. Even when I re-install the module and deleted the class_index.php What else do I need to do? Link to comment Share on other sites More sharing options...
Eolia Posted September 9, 2014 Share Posted September 9, 2014 try this.... <?php class AdminRenderPdf extends AdminModulesController { .... //or <?php class AdminRenderPdf extends AdminController { .... // It's depend of the job 1 Link to comment Share on other sites More sharing options...
PhpMadman Posted September 9, 2014 Author Share Posted September 9, 2014 (edited) None of the above works. Even tried renaming to AdminRenderPdfController index.php?controller=AdminRenderPdf Still says controller not found *EDIT* As for the job. It's similar to the real AdminPdfController but it will have some additions and tweaks. Edited September 9, 2014 by PhpMadman (see edit history) Link to comment Share on other sites More sharing options...
irrelevant Posted September 9, 2014 Share Posted September 9, 2014 (edited) If it helps, I'm also doing a module that affects that file... I've just put an AdminPdfController.php in the module's /modules/my-module/override/controllers/admin/ folder. This starts class AdminPdfController extends AdminPdfControllerCorewhich seems to work. Not quite the same thing, but might help?? Edited September 9, 2014 by irrelevant (see edit history) 1 Link to comment Share on other sites More sharing options...
PhpMadman Posted September 9, 2014 Author Share Posted September 9, 2014 Yeah. I though of that too. I can create a override file that adds my functions. But I don't know... It seams like the wrong thing to do. But yes, it's a good idea. Link to comment Share on other sites More sharing options...
PhpMadman Posted September 9, 2014 Author Share Posted September 9, 2014 I'm been goggling this a lot, All I can find is that my code is correct. It just dosent work for some reason. So to get what I wanted in admin, I decied to link to my working front pdf render instead. It's not the standard way, but it works. Link to comment Share on other sites More sharing options...
irrelevant Posted September 9, 2014 Share Posted September 9, 2014 It seems to work... If you call it with e.g. Tools::redirectAdmin($this->context->link->getAdminLink('AdminPdf').'&submitAction=generateMyModule&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')));(c.f. AdminDeliverySlipController.php) Then all your override needs to do is add a function public function processGenerateMyModule()- no need to actually amend anything existing - it gets found automatically. (but note the capitalisation of the G!) Link to comment Share on other sites More sharing options...
PhpMadman Posted September 9, 2014 Author Share Posted September 9, 2014 Hi. Maybe I was a bit unclear. It's my new Admin Controller that does not work, from first post. I have not tried with the override. I don't like to use overrides, not even for adding functions. Even tho this module must use some overrides to work. I try to keep the code to a minimum. But I might need to add the override anyway. I'm gonna sell it on addon site. So they might fail it due to that litle hack... Yeah.. I think I'll rewrite it to use AdminPdfController override... Link to comment Share on other sites More sharing options...
irrelevant Posted September 9, 2014 Share Posted September 9, 2014 Ah gotcha.... Not sure if it's the same as you need, but my module adds an admin controller ("AdminMyModuleController.php") using class AdminMyModuleController extends ModuleAdminController, which is then called from the Orders menu (created via $this->installModuleTab('AdminMyModule', 'My Module', Tab::getIdFromClassName('AdminOrders'))) Link to comment Share on other sites More sharing options...
PhpMadman Posted September 9, 2014 Author Share Posted September 9, 2014 Thanks all for your input. I still have no idea why I just couldn't create a new Admin Controller. But as irrelevant suggested, I extended AdminPdfController instead. @irrelevant That adds the controller to the menu. The controller I wanted should work in background, never to be seen by user. Link to comment Share on other sites More sharing options...
Amazzing Posted January 16, 2015 Share Posted January 16, 2015 (edited) It looks like module admin controllers depend on tabs. So if you want to activate an admin controller you have to create a corresponding tab, and if you don't want it to be included in menu, you can just hide it by setting $tab->id_parent = -1so, first you create a file here: /controllers/admin/AdminYourModuleNameSpecialControllerName.php <?php class AdminYourModuleNameSpecialControllerNameController extends ModuleAdminController { public function __construct() { parent::__construct(); // do your stuff here } } Then you create a method for adding tab and run it on module installSomething like this: public function install() { ... if (!parent::install() || !$this->addTab() ...) return false; return true; } public function addTab() { $tab = new Tab(); $tab->name = array(); foreach (Language::getLanguages() as $language) $tab->name[$language['id_lang']] = 'AdminYourModuleNameSpecialControllerName'; $tab->class_name = 'AdminYourModuleNameSpecialControllerName'; // if id_parent = -1, tab will not be visible in menu $tab->id_parent = -1; $tab->module = $this->name; if(!$tab->add()) return false; return true; } This may not be the official way of activating an admin module controller, but I didn't find any documentation on this point, so I currently use this way and it works fine. Edited January 16, 2015 by Amazzing (see edit history) 2 Link to comment Share on other sites More sharing options...
stathis Posted May 7, 2015 Share Posted May 7, 2015 It looks like module admin controllers depend on tabs. So if you want to activate an admin controller you have to create a corresponding tab, and if you don't want it to be included in menu, you can just hide it by setting $tab->id_parent = -1 so, first you create a file here: /controllers/admin/AdminYourModuleNameSpecialControllerName.php <?php class AdminYourModuleNameSpecialControllerNameController extends ModuleAdminController { public function __construct() { parent::__construct(); // do your stuff here } } Then you create a method for adding tab and run it on module install Something like this: public function install() { ... if (!parent::install() || !$this->addTab() ...) return false; return true; } public function addTab() { $tab = new Tab(); $tab->name = array(); foreach (Language::getLanguages() as $language) $tab->name[$language['id_lang']] = 'AdminYourModuleNameSpecialControllerName'; $tab->class_name = 'AdminYourModuleNameSpecialControllerName'; // if id_parent = -1, tab will not be visible in menu $tab->id_parent = -1; $tab->module = $this->name; if(!$tab->add()) return false; return true; } This may not be the official way of activating an admin module controller, but I didn't find any documentation on this point, so I currently use this way and it works fine. At last, after a week of trying, a working example! MANY thanks! Link to comment Share on other sites More sharing options...
Sandeep Tiwari Posted October 26, 2015 Share Posted October 26, 2015 Hello stathisI followed your way and indeed module added a tab but when I click the link it says ""controller not found". Please help. Link to comment Share on other sites More sharing options...
Sandeep Tiwari Posted October 26, 2015 Share Posted October 26, 2015 It looks like module admin controllers depend on tabs. So if you want to activate an admin controller you have to create a corresponding tab, and if you don't want it to be included in menu, you can just hide it by setting $tab->id_parent = -1 so, first you create a file here: /controllers/admin/AdminYourModuleNameSpecialControllerName.php <?php class AdminYourModuleNameSpecialControllerNameController extends ModuleAdminController { public function __construct() { parent::__construct(); // do your stuff here } } Then you create a method for adding tab and run it on module install Something like this: public function install() { ... if (!parent::install() || !$this->addTab() ...) return false; return true; } public function addTab() { $tab = new Tab(); $tab->name = array(); foreach (Language::getLanguages() as $language) $tab->name[$language['id_lang']] = 'AdminYourModuleNameSpecialControllerName'; $tab->class_name = 'AdminYourModuleNameSpecialControllerName'; // if id_parent = -1, tab will not be visible in menu $tab->id_parent = -1; $tab->module = $this->name; if(!$tab->add()) return false; return true; } This may not be the official way of activating an admin module controller, but I didn't find any documentation on this point, so I currently use this way and it works fine. This is still not working , tab is added but same error "controller not found". 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