我是Prestashop 1.7的新手。我需要覆盖一个css。我在Prestashop附带的custom.css上编写了css代码。当我刷新网站时,自定义css不适用。没有链接rel指向该文件。
我想问一下如何调用custom.css。有一个stylesheets.tpl,但我不确定要编写什么代码。
答案 0 :(得分:1)
您可以添加自定义CSS& JS在最新的PrestaShop中使用setMedia()函数,它位于frontController中,如下图所示:
路径:mainDir / classes / controller / FrontController.php
public function setMedia()
{
$this->registerStylesheet('theme-main', '/assets/css/theme.css', ['media' => 'all', 'priority' => 50]);
$this->registerStylesheet('theme-custom', '/assets/css/custom.css', ['media' => 'all', 'priority' => 1000]);
if ($this->context->language->is_rtl) {
$this->registerStylesheet('theme-rtl', '/assets/css/rtl.css', ['media' => 'all', 'priority' => 900]);
}
$this->registerJavascript('corejs', '/themes/core.js', ['position' => 'bottom', 'priority' => 0]);
$this->registerJavascript('theme-main', '/assets/js/theme.js', ['position' => 'bottom', 'priority' => 50]);
$this->registerJavascript('theme-custom', '/assets/js/custom.js', ['position' => 'bottom', 'priority' => 1000]);
$assets = $this->context->shop->theme->getPageSpecificAssets($this->php_self);
if (!empty($assets)) {
foreach ($assets['css'] as $css) {
$this->registerStylesheet($css['id'], $css['path'], $css);
}
foreach ($assets['js'] as $js) {
$this->registerJavascript($js['id'], $js['path'], $js);
}
}
// Execute Hook FrontController SetMedia
Hook::exec('actionFrontControllerSetMedia', array());
return true;
}
答案 1 :(得分:0)
您只需将其复制到主题的assets / css文件夹
即可