不能用cakePHP html helper添加css版本控制

问题描述 投票:1回答:2

我希望在我的css文件中添加一个版本号,但我没有看到使用html帮助程序的方法。

我看到一个通过bootstrap.php添加时间戳的示例,但我希望能够自己控制版本号。

我正在使用cakephp 2.3

style.min.css?V = 1

<?php
    echo $this->Html->css('style.min', array('v'=>'1'));
    echo $this->fetch('css');
?>

要么

<?php
    echo $this->Html->css('style.min?v=1');
    echo $this->fetch('css');
?>
cakephp cakephp-2.3
2个回答
3
投票

只需添加.css

echo $this->Html->css('style.min.css?v=1');

尽管省略.css是标准做法,但包含它是可以接受的,并允许您在URL的末尾添加其他参数。


0
投票

在CakePHP 3x中,您可以在config/app.php中执行此操作。

/**
 * Apply timestamps with the last modified time to static assets (js, css, images).
 * Will append a querystring parameter containing the time the file was modified.
 * This is useful for busting browser caches.
 *
 * Set to true to apply timestamps when debug is true. Set to 'force' to always
 * enable timestamping regardless of debug value.
 */
'Asset' => [
    // 'timestamp' => true,
],
© www.soinside.com 2019 - 2024. All rights reserved.