Reputation: 103
I create a custom module in which I want to add new option to client list. By default the user can use options: view, edit or delete. I want to add check option. For this test I modify the main controller AdminCustomersControllerCore without override.
In \controllers\admin\AdminCustomersController.php
public function displayEraseLink($token = null, $id, $name = null) {
$tpl = $this->createTemplate(_PS_MODULE_DIR_ . $this->module->name.'/views/templates/admin/list_action_erase.tpl');
$tpl->assign(array(
'confirm' => $this->l('Erase all client data') . $name,
'action' => $this->l('Erase'),
'id' => $id,
));
return $tpl->fetch();
}
I want to load list_action_erase.tpl which is location in modules\my_module\views\templates\admin\list_action_erase.tpl. In server log I see:
Unable to load template file '/home/user/domains/domain.com/public_html/admin3640wjafn/themes/default/template//home/user/domains/domain.com/public_html/modules//views/templates/admin/list_action_erase.tpl
How to load view from another location ?
Kind regards
Upvotes: 0
Views: 1127
Reputation: 4337
Instead of
$tpl = $this->createTemplate(_PS_MODULE_DIR_ . $this->module->name.'/views/templates/admin/list_action_erase.tpl');
use
$tpl = $this->context->smarty->createTemplate(_PS_MODULE_DIR_ . $this->module->name.'/views/templates/admin/list_action_erase.tpl');
$this->createTemplate()
is a wrapper for $this->context->smarty->createTemplate()
in AdminController
which will look for a template relative to folder /adminfolder/themes/default/template/
.
Using $this->context->smarty->createTemplate()
itself you can specify absolute path to your template.
Upvotes: 2