Kerel Posted May 15, 2014 Share Posted May 15, 2014 Hi, I have a module which displays table in DisplayAdminProductsExtra hook, and there are links to another controller extending ModuleAdminController. Controller is in my_module/controllers/admin/ link is: index.php?controller=AdminDetailSpecificationTables It didn't work for first time - but I've created link to the menu tab and now it works (strange) However, controller is loaded, but not template. When I use $this->setTemplate('display.tpl'); and my template is in my_module/views/templates/admin/display.tpl It showss me this error: Unable to load template file 'D:\wamp\www\xxx\adminyyyy/themes/default\template\display.tpl' which is a little bit strange, url is broken. I am getting frustrated. If you could help, I would really appreciate it Thanks! Link to comment Share on other sites More sharing options...
Kerel Posted May 16, 2014 Author Share Posted May 16, 2014 bump? Link to comment Share on other sites More sharing options...
Kerel Posted May 16, 2014 Author Share Posted May 16, 2014 Thanks so much!!! Have to find correct folder: detail_specification_tables instead of detailspecificationtables Also don't understand why it should be my_module/views/templates/admin/my_module, theres nothing about it in the documentation. Documentation sucks very badly - why prestashop doesn't have documentation like wordpress? Really, thanks so much! I was quite depressed with this, struggling few hours. 2 Link to comment Share on other sites More sharing options...
zouhairHajji Posted August 25, 2015 Share Posted August 25, 2015 i have the same problem,but i did the same step like you, but i still have the same problem.my error is : Fatal error: Uncaught --> Smarty: Unable to load template file 'C:\xampp\htdocs\prestashop\admin215kx66zt/themes/default\template\symstick' <-- thrown in C:\xampp\htdocs\prestashop\tools\smarty\sysplugins\smarty_internal_templatebase.php on line 129 class AdminSynchroController extends ModuleAdminController { public function __construct() { parent::__construct(); $this->tpl_folder = 'symstick'; $this->setTemplate($this->tpl_folder); } cou can help me please ? Link to comment Share on other sites More sharing options...
zouhairHajji Posted August 25, 2015 Share Posted August 25, 2015 i overrided the method createTemplate($template) public function __construct() { parent::__construct(); $this->template = 'displayAdmin.tpl'; } public function createTemplate($tpl_name) { // Use override tpl if it exists // If view access is denied, we want to use the default template that will be used to display an error if ($this->viewAccess() && $this->override_folder) { if (file_exists($this->context->smarty->getTemplateDir(1) . DIRECTORY_SEPARATOR . $this->override_folder . $tpl_name)) return $this->context->smarty->createTemplate($this->override_folder . $tpl_name, $this->context->smarty); elseif (file_exists($this->context->smarty->getTemplateDir(0) . 'controllers' . DIRECTORY_SEPARATOR . $this->override_folder . $tpl_name)) return $this->context->smarty->createTemplate('controllers' . DIRECTORY_SEPARATOR . $this->override_folder . $tpl_name, $this->context->smarty); } return $this->context->smarty->createTemplate(_PS_MODULE_DIR_.'symstick\views\templates\admin\symstick/'. $tpl_name, $this->context->smarty); } and now it work, i don't know if i can use it like that or non Link to comment Share on other sites More sharing options...
01generator Posted July 6, 2023 Share Posted July 6, 2023 (edited) Just bumbed in to this via search. Old post I know, but if anyone gets here this might help him/her I use class MyModuleModuleFrontController extends ModuleFrontController { /* Conctructor of the controller */ public function __construct() { parent::__construct(); } public function initContent() { parent::initContent(); // possible variables you want to use in tpl $this->context->smarty->assign( array( 'var1' => $var1, 'var2' => $var2, ) ); if (version_compare(_PS_VERSION_, '1.7.0.0 ', '<')) { // must be in folder modulename/views/templates/front/ return $this->setTemplate('front16.tpl'); } else { // must be in folder modulename/views/templates/front/ $this->setTemplate('module:MyModule/views/templates/front/front17.tpl'); } } } Replace MyModule with your module name, variables, filename etc. Edited July 6, 2023 by 01generator (see edit history) 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