0
votes

I have Prestashop 1.7.2.1 installed and I'm trying to write a module for it.

In general I just want to test bootstrap (4 ?) support.

I created a hook in my module for displayTop and It loads the following smarty template:

<div class="alert alert-primary" role="alert">
    This is a primary alert—check it out!
</div>

but unfortunately this does not add the proper bootstrap css style to my module.

this is the constructor of my module:

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

I googled that I need to use $this->bootstrap=true; but actually ModuleCore doesn't contain bootstrap property.

I install my module with the following function:

public function install() {

return (parent::install()  && $this->loadSqlFile(__DIR__.DIRECTORY_SEPARATOR.'sql'.
DIRECTORY_SEPARATOR.'install.sql') &&
        $this->registerHook('displayBackOfficeHeader') &&
$this->registerHook('displayAdminProductsExtra') &&
$this->registerHook('displayTop'));

}

and the hookDisplayTop as the following code:

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

here in $this->context->controller I found a bootsrap variable but it also doesn't change anything.

any ideas?

1

1 Answers

1
votes

Bootstrap 4 doesn't have alert-primary class at least from looking at the documentation. I injected your html snippet into prestashop demo page and I don't get any styling. However using any other alert-success, alert-info etc. all show proper styling.