Adrian Posted February 19, 2018 Share Posted February 19, 2018 (edited) Dear Community, At this moment im trying to implement on my shop (PRESTASHOP 1.6.1.17) a modification that adds to the css files a version so I can ensure that the client is going to reload the page with the latest version: The result that I would like is something like <link rel="stylesheet" href="/url_path/mystyles.css?v=123" type="text/css" media="all" /> I have been searching for a solution and I found a thread from 2011 and updated last year, but i'm not able to run it correctly. Thread: https://www.prestashop.com/forums/topic/136126-auto-versioning-css-files-force-css-refresh/ (I tried creating an override with the last comment of this thread and it don't seem to work). I hope someone can help me or at least give me the idea of how to do it. Thanks in advance. Edited February 27, 2018 by Adrian (see edit history) Link to comment Share on other sites More sharing options...
Adrian Posted February 20, 2018 Author Share Posted February 20, 2018 Up! Link to comment Share on other sites More sharing options...
Adrian Posted February 22, 2018 Author Share Posted February 22, 2018 up!Up! Link to comment Share on other sites More sharing options...
sharkooon Posted February 26, 2018 Share Posted February 26, 2018 (edited) fixed it: add to /override/classes/assets/StylesheetManager.php <?php class StylesheetManager extends StylesheetManagerCore { protected function add($id, $fullPath, $media, $priority, $inline, $server) { if ('local' === $server && !$inline) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . $fullPath)) { $version = filemtime($_SERVER['DOCUMENT_ROOT'] . $fullPath); } else { $version = '1'; } $fullPath = $fullPath . '?v=' . $version; } parent::add($id, $fullPath, $media, $priority, $inline, $server); } } Edited February 26, 2018 by sharkooon (see edit history) Link to comment Share on other sites More sharing options...
Adrian Posted February 27, 2018 Author Share Posted February 27, 2018 On 2/26/2018 at 8:43 PM, sharkooon said: fixed it: add to /override/classes/assets/StylesheetManager.php <?php class StylesheetManager extends StylesheetManagerCore { protected function add($id, $fullPath, $media, $priority, $inline, $server) { if ('local' === $server && !$inline) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . $fullPath)) { $version = filemtime($_SERVER['DOCUMENT_ROOT'] . $fullPath); } else { $version = '1'; } $fullPath = $fullPath . '?v=' . $version; } parent::add($id, $fullPath, $media, $priority, $inline, $server); } } Expand Thank you for your help but in Prestashop 1.6 I do not find the class StylesheetManager, searching on Google it seems to be for Prestashop 1.7 . Thank you anyway Link to comment Share on other sites More sharing options...
sharkooon Posted February 27, 2018 Share Posted February 27, 2018 Yes sorry it is for 1.7 Link to comment Share on other sites More sharing options...
Adrian Posted March 9, 2018 Author Share Posted March 9, 2018 Up!! Link to comment Share on other sites More sharing options...
Guest Posted March 9, 2018 Share Posted March 9, 2018 Anything here to help? https://stackoverflow.com/questions/11474345/force-browser-to-refresh-css-javascript-etc Link to comment Share on other sites More sharing options...
gafonso Posted July 22, 2019 Share Posted July 22, 2019 (edited) Hi, is this still working in prestashop 1.7? Do i need to do something else to the theme.css file or just add that code to StylesheetManager.php? EDIT: forgot to delete app\cache\prod\class_index.php after the override. Working now! Edited July 22, 2019 by gafonso (see edit history) Link to comment Share on other sites More sharing options...
Antoine-OH Posted January 24, 2020 Share Posted January 24, 2020 (edited) Hi if you're problem is still there, look at this, it helped me a lot : https://www.prestashop.com/forums/topic/136126-auto-versioning-css-files-force-css-refresh/?tab=comments#comment-2557953 Edited January 24, 2020 by Antoine-OH (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now