我的问题是如何将新的 css_style 文件添加到 opencart 中的主题中?

my question is about how can i add my new css_style file to the theme in opencart?

例如,在我的主页上,我希望使用与默认样式不同的样式sheet,或者使用我的自定义 sheet 覆盖默认样式的样式。

我尝试了很多解决方案,但没有任何结果可以帮助我找到正确的方向。

因此,您可以通过多种方式在 OpenCart 主题中添加样式表

简单的方法

在文件 catalog/view/theme/YOUR_THEME/template/common/header.twig add the link to your stylesheet in< head >` 中,紧跟在上一个 css 文件之后。

remember that your custom stylesheet has to go after your default stylesheet for the styles to override them.

<link href="catalog/view/theme/YOUR_THEME/stylesheet/CUSTOM_STYLESHEET.css" rel="stylesheet">

更复杂的方式

OpenCart 允许您从控制器设置样式表。这通常被模块用来将它们的样式添加到 head 标记中,还允许站点优化模块压缩样式表文件。

你可以通过编辑主页的控制器文件来测试它(作为例子)

line 7 上的文件 catalog/controller/common/home.php 中添加此代码

$this->document->addStyle('catalog/view/theme/YOUR_THEME/stylesheet/CUSTOM_STYLESHEET.css');

希望对您有所帮助