This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi how you can get the latest file change and deduce the URL of the file: <link href="style.css?v=00000" rel="stylesheet">
Hi, I don't quite understand what do you mean, can you please clarify your question in other words?
@gohhan, it's feasible but I don't suggest it because it slows down your request even more when checking the file timestamp on disk... what I usually do is this:
<link rel="stylesheet" href="{{ 'assets/css/style.css' | theme ~ '?v=1.0.1' }}">
And I manually increment the version number when the file changes.
But if you REALLY want the code to check this automatically everytime, I can suggest a way to do this, just let me know.
mjauvin said:
@gohhan, it's feasible but I don't suggest it because it slows down your request even more when checking the file timestamp on disk... what I usually do is this:
<link rel="stylesheet" href="{{ 'assets/css/style.css' | theme ~ '?v=1.0.1' }}">
And I manually increment the version number when the file changes.
But if you REALLY want the code to check this automatically everytime, I can suggest a way to do this, just let me know.
What about cashing? Will you turn to the file every time you load the page? I'd be happy if you send the code. There are projects that often have changes and it is not always convenient to manually change the version of the file.
Last updated
Here's one way to do this.
In your layout, replicate the example below:
description = default layout
==
function onInit()
{
$styleAsset = 'assets/css/style.css';
$lastUpdate = filemtime($this->theme->getPath() . '/' . $styleAsset);
$this['stylesheet'] = sprintf('%s?v=%s', $this->controller->themeUrl($styleAsset), $lastUpdate);
}
==
...
<link rel="stylesheet" href="{{ stylesheet }}">
...
mjauvin said:
Here's one way to do this.
In your layout, replicate the example below:
description = default layout == function onInit() { $styleAsset = 'assets/css/style.css'; $lastUpdate = filemtime($this->theme->getPath() . '/' . $styleAsset); $this['stylesheet'] = sprintf('%s?v=%s', $this->controller->themeUrl($styleAsset), $lastUpdate); } == ... <link rel="stylesheet" href="{{ stylesheet }}"> ...
Thank you! It's working!
1-9 of 9