I am developing a module Abc for PrestaShop 1.5
This is my dir
23/10/2012 18:23 1.307 index.php
07/12/2012 18:27 <DIR> tpl
-> tpl dir:
07/12/2012 18:27 <DIR> .
07/12/2012 18:27 <DIR> ..
07/12/2012 18:39 543 form.tpl
07/12/2012 18:36 4.507 abc.php
this is the code i use:
class Abc extends Module
{
public function getContent()
{
return $this->display(dirname(__FILE__), 'tpl/form.tpl');
}
...
}
however when i use smarty {debug} to print all variables
i don’t get the variables {img_dir} or {shop_name} like i should according to The official documentation.
I am confused of where to place the template, where the theme, and so on. I only need backoffice(backend) pages. What am i doing wrong?
Thank you
Smarty variables have global scope. It means that they can be assigned in one file and you will be able to use anywhere and during all life cycle of your script. This way, when you fire hook or use your own tpl on frontend, no matter which controller you use, most likely (although there can be exception for overriding controller) method
FrontController::init()will be excecuted. In this method most of these global smarty variables are assigned(http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-UsingSmarty):Using hook in admin panel,
FrontController::init()are not excecuted, and that’s way you need to assign all these variables in order to use them inside your files.But anywhere in admin panel you can use module_dir and module_template_dir which are assigned in method
Module::display().