我尝试使用以下 PHP 脚本创建一个 CSS 文件: 集成在 OpenCart 中以减少 http 请求。
...\catalog\controller\common\css.php:
class ControllerCommonCss extends Controller {
public function index() {
$this->log->write('test');
$cssFiles = array(
"stylesheet.css",
);
$buffer = "";
foreach ($cssFiles as $cssFile) {
$buffer .= file_get_contents($cssFile);
...
}
}
}
标题.tpl:
<link rel="stylesheet" href="catalog/controller/common/css.php" type="text/css" media="screen">
error.log 中的输出“test”不起作用。并且样式表不会加载到标题中。有人能告诉我怎么了吗?
问候
最佳答案
您也可以使用像 NitroPack Cache 这样的扩展来执行此操作以及加载其他内容: https://docs.isenselabs.com/nitropack/minification
关于php - css 脚本 opencart 与 php 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54866295/