【问题标题】:using bootstrap 4 with prestashop 1.7.2.1 module使用带有 prestashop 1.7.2.1 模块的 bootstrap 4
【发布时间】: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-&gt;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-&gt;context-&gt;controller 中,我发现了一个bootsrap 变量,但它也没有改变任何东西。

有什么想法吗?

【问题讨论】:

    标签: prestashop prestashop-1.7


    【解决方案1】:

    至少从 documentation 来看,Bootstrap 4 没有 alert-primary 类。我将您的 html sn-p 注入 prestashop 演示页面,但没有得到任何样式。然而,使用任何其他alert-successalert-info 等都显示出正确的样式。

    【讨论】:

      猜你喜欢
      • 2018-05-23
      • 2020-02-21
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多