【发布时间】:2018-01-03 01:45:10
【问题描述】:
我正在学习为 prestashop 1.7 编写模块,目前我正在尝试加载用户尝试配置模块时将使用的 css 和 js 文件。
这是我的模块的代码:
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"。
我对此真的很陌生..我读到我需要在前端控制器中设置它..但这是否意味着它将出现在常规页面而不是配置页面中?
不知道如何解决这个问题并且有点困惑,因此非常感谢任何有关此问题的信息。
【问题讨论】:
标签: php prestashop prestashop-1.7