【发布时间】:2018-01-27 21:35:39
【问题描述】:
我已经安装了 Prestashop 1.7.2.1,我正在尝试为它编写一个模块。
一般来说,我只想测试 bootstrap (4 ?) 支持。
我在我的模块中为 displayTop 创建了一个钩子,它加载了以下 smarty 模板:
<div class="alert alert-primary" role="alert">
This is a primary alert—check it out!
</div>
但不幸的是,这并没有为我的模块添加正确的引导 css 样式。
这是我的模块的构造函数:
class TuxInModCarType extends Module
{
function __construct()
{
$this->csvUtil = new CsvUtil(buildCsvArray());
$this->ret = new RetObj();
$this->name = 'tuxinmodcartype';
$this->tab = 'quick_bulk_update';
$this->version = '0.1';
$this->author = 'Kfir Ozer';
$this->bootstrap = true;
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
parent::__construct();
$this->displayName = 'Tux-In Car Type';
$this->description = 'With this module, you will be able to specify car types for products';
$this->confirmUninstall = $this->l('Are you sure you want to uninstall');
if (!Configuration::get('MYMODULE_NAME'))
$this->warning = $this->l('No name provided');
}
我用谷歌搜索说我需要使用$this->bootstrap=true;,但实际上ModuleCore 不包含引导属性。
我使用以下功能安装我的模块:
公共函数安装(){
return (parent::install() && $this->loadSqlFile(__DIR__.DIRECTORY_SEPARATOR.'sql'.
DIRECTORY_SEPARATOR.'install.sql') &&
$this->registerHook('displayBackOfficeHeader') &&
$this->registerHook('displayAdminProductsExtra') &&
$this->registerHook('displayTop'));
}
和hookDisplayTop 如下代码:
public function hookDisplayTop() {
$this->context->controller->addJquery();
$this->context->controller->bootstrap=true;
$this->context->controller->addCSS($this->_path.'/css/displaytop.css');
$this->context->controller->addJS($this->_path.'/js/displaytop.js');
return $this->display(__FILE__,'/displayTop.tpl');
}
在$this->context->controller 中,我发现了一个bootsrap 变量,但它也没有改变任何东西。
有什么想法吗?
【问题讨论】: