Prestashop将css添加到模块中

Ben*_*ier 3 css php module prestashop

我在prestashop 1.4中创建了一个模块 blocktest

模块/ blocktest/blocktest.php:

...

public function hookLeftColumn($params)
{
    global $smarty;
    $smarty->assign(array(
        'test' => 'test'
    ));
    return $this->display(__FILE__, 'blocktest.tpl');
}

public function hookHeader()
{
    Tools::addCSS($this->_path.'blocktest.css', 'all');
}
Run Code Online (Sandbox Code Playgroud)

模块/ blocktest/blocktest.css:

* { background-color: red; }
Run Code Online (Sandbox Code Playgroud)


问题:

我的css不包括在内.


我尝试了什么:

admin > preferences > performances > smarty,我已设置缓存no,并强制编译yes.在admin > preferences > performances > smarty,缓存设置为no.

现有模块使用相同的css包含:Tools::addCSS($this->_path.'blocktest.css', 'all');,但css文件位于<themeName>/css/modules/<moduleName>/<moduleName>.css.哪个是奇怪的,因为$ this - > _ path指向模块文件夹:modules/<moduleName>/.

但无论如何,我试图将我的css文件放入 <themeName>/css/modules/blocktest/blocktest.css,这不起作用.也许我错过了什么

Mat*_*rek 5

您还记得在模块安装期间注册标题的钩子吗?

function install() {
    if (!parent::install())
        return false;
    if (!$this->registerHook('header'))
        return false;
    return true;
}
Run Code Online (Sandbox Code Playgroud)

没有它,您将不得不使用Admin> Modules> Positions中的"移植模块"功能来执行此操作.请务必使用Firebug等工具进行检查,以验证您的文件是否存在.

另外,我认为有些东西缺失了,你能为我们提供模块的完整代码吗?请向我们提供您使用的Prestashop版本.