使用 bootstrap 4 与 prestashop 1.7.2.1 模块
using bootstrap 4 with prestashop 1.7.2.1 module
我安装了 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>
但不幸的是,这并没有将正确的 bootstrap 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
不包含 bootstrap 属性.
我使用以下功能安装我的模块:
public 函数安装() {
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
变量,但它也没有改变任何东西。
有什么想法吗?
Bootstrap 4 没有 alert-primary
class 至少从 documentation 来看是这样。我将您的 html 代码片段注入了 prestashop 演示页面,但我没有得到任何样式。但是,使用任何其他 alert-success
、alert-info
等都显示出正确的样式。
我安装了 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>
但不幸的是,这并没有将正确的 bootstrap 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
不包含 bootstrap 属性.
我使用以下功能安装我的模块:
public 函数安装() {
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
变量,但它也没有改变任何东西。
有什么想法吗?
Bootstrap 4 没有 alert-primary
class 至少从 documentation 来看是这样。我将您的 html 代码片段注入了 prestashop 演示页面,但我没有得到任何样式。但是,使用任何其他 alert-success
、alert-info
等都显示出正确的样式。