I'm learning to write modules to prestashop 1.7, currently I'm trying to load css and js files that will be used when the user tried to configure the module.
this is the code of my module:
class TuxInModComments extends Module
{
function __construct()
{
$this->name = 'tuxinmodcomments';
$this->tab = 'quick_bulk_update';
$this->version = '0.1';
$this->author = 'Kfir Ozer';
$this->displayName = 'Tux-In Comments and Ranks';
$this->description = 'With this module, your costumers will be able to grade and comment your products';
$this->bootstrap = true;
parent::__construct();
}
public function install() {
parent::install();
$this->registerHook('actionAdminControllerSetMedia');
return true;
}
public function processConfiguration()
{
if (Tools::isSubmit('mymod_pc_form')) {
$enable_grades = Tools::getValue('enable_grades');
$enable_comements = Tools::getValue('enable_comments');
$csvFile = Tools::getValue('csv_file');
die(var_export($csvFile));
Configuration::updateValue('MYMOD_GRADES', $enable_grades);
Configuration::updateValue('MYMOD_COMMENTS', $enable_comements);
$this->context->smarty->assign('confirmation', 'ok');
}
}
public function assignConfiguration()
{
$enable_grades = Configuration::get('MYMOD_GRADES');
$enable_comments = Configuration::get('MYMOD_COMMENTS');
$this->context->smarty->assign('enable_grades', $enable_grades);
$this->context->smarty->assign('enable_comments', $enable_comments);
}
public function hookActionAdminControllerSetMedia($params){
$this->registerStylesheet('module-tuxinmodcomments-css','modules/tuxinmodcomments/js/getcontent.css');
$this->registerJavascript('module-tuxinmodcomments-js','modules/tuxinmodcomments/js/getcontent.js');
}
public function getContent() {
$this->processConfiguration();
$this->assignConfiguration();
return $this->display(__FILE__,'getContent.tpl');
}
}
so I registered the admin set Media hook with the name actionAdminControllerSetMedia
but it seems that it doesn't have the functions to set stylesheet and javascript cause I get the same error for both: Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "registerStylesheet" OR "registerJavascript" of class "AdminModulesController"
.
I'm really new to this.. I read that I need to set it in the front controller.. but doesn't that mean that it will appear in the regular page and not in the configuration page?
don't know how to resolve this and a bit confused, so any information regarding the issue would be greatly appreciated.