Skip to content

Instantly share code, notes, and snippets.

@delphinpro
Created November 5, 2019 14:52
Show Gist options
  • Save delphinpro/e99f1637176fd17eafd5ba356e97c6f2 to your computer and use it in GitHub Desktop.
Save delphinpro/e99f1637176fd17eafd5ba356e97c6f2 to your computer and use it in GitHub Desktop.
Антикэш стилей для Modx
<?php
/*
Usage:
[[includeStylesheet? &file=`/path/to/style.css` ]]
*/
if (!isset($file)) {
return '';
}
$filePath = MODX_BASE_PATH.$file;
if (!is_file($filePath) or !is_readable($filePath)) {
return '<!-- FILE NOT FOUND: '.$file.' --><script>console.error("FILE NOT FOUND: '.$file.'")</script>';
}
$time = filemtime($filePath);
return '<link rel="stylesheet" href="'.$file.'?v='.$time.'">';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment