Hi,
in my themes, I use the following PHP code to attach a version number (= last time the file content was modified) to the path of the CSS file in the HTML-output to prevent browsers using the cached css-file after some CSS file changes. It is stored as head_css.php
in the templates folder:
<?php defined('AUTOMAD') or die('Direct access not permitted!');
function autoversion_css($url) {
$path = pathinfo($url);
$ver = '?v='.filemtime($_SERVER['DOCUMENT_ROOT'].$url);
return $path['dirname'].'/'. $path['basename'] . $ver; } ?>
<link rel="stylesheet" href="<?php echo autoversion_css('/packages/site/templates/css/styles.css'); ?>">
The HTML output will look something like this:
<link rel="stylesheet" href="/packages/site/templates/css/styles.css?v=1650800976">
In my template I use <@ head_css.php @>
to include the HTML-output.
In Automad Version 1.7.2 it works perfectly, but after updating Automad to the newerst version I just get a blank page if I include head_css.php
in my page template.
If I delete defined('AUTOMAD') or die('Direct access not permitted!');
to be able to run head_css.php
directly by typing the URL of head_css.php
file in the browser for testing, I get a correct output.
How can I get the output of head_css.php
in the template?
Many thanks for your help!