Last active
January 30, 2022 00:04
-
-
Save nobodyplace/3549a40e4335eeb5388a94a868389c0d to your computer and use it in GitHub Desktop.
Smartyでファイルの更新日時を付与する動的プラグイン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DisplayManager | |
{ | |
function __construct() | |
{ | |
$this->_smarty->registerPlugin('function', 'filemtime', array($this, 'smarty_function_filemtime')); | |
} | |
public function smarty_function_filemtime($params, $smarty) | |
{ | |
$file = $params['file']; | |
return $file.'?'.filemtime($_SERVER['DOCUMENT_ROOT'].$file); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--{filemtime file="/css/reset.css"}--> | |
→ /css/reset.css?1632201991 と出力される |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
制限事項:CSSを絶対パスで指定する必要がある