试图加载js和css文件在prestashop 1.7管理模块

问题描述:

我正在学习编写模块到prestashop 1.7,目前我试图加载用户尝试配置模块时将使用的css和js文件。试图加载js和css文件在prestashop 1.7管理模块

这是我模块的代码:

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'); 
    } 

} 

所以我注册了一个名为actionAdminControllerSetMedia管理员组媒体钩,但它似乎不具备的功能设置样式表和javascript因为我得到两者的相同错误:Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "registerStylesheet" OR "registerJavascript" of class "AdminModulesController"

我真的很新这个..我读过,我需要将它设置在前端控制器..但这并不意味着它会出现在常规页面,而不是在配置页面?

不知道如何解决这个问题,有点困惑,所以关于这个问题的任何信息将不胜感激。

要加载CSS或JS你有恩用这个钩子,在这个片段:

public function hookDisplayBackOfficeHeader() 
{ 
    $this->context->controller->addCSS($this->_path.'pathtocss/module.css', 'all'); 
    $this->context->controller->addJS($this->_path.'pathtojs/module.js', 'all'); 
} 

享受:)

PS:您必须先注册显示后台头钩第一