File tree Expand file tree Collapse file tree 5 files changed +85
-0
lines changed
Expand file tree Collapse file tree 5 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ /vendor /
Original file line number Diff line number Diff line change 1+ # Version parameter for [ OpenCart 2.x] ( https://github.com/opencart/opencart )
2+
3+ Helper function which fixing visitors browser cache issue after your changes at CSS or javascript
4+
5+ ## Preview
6+
7+ ![ Source code] ( ./doc/source_code.png )
8+
9+ You can also use this function for your custom files (CSS / JS, images, ...) like this:
10+ ``
11+ <link href =" <?php echo versionNumber($style['href']); ?> " type =" text/css " rel ="<?php echo $style['rel']; ? >
12+ ``
13+
14+ ## Installation
15+
16+ 1 . Requiring installed [ vQmod] ( https://github.com/vqmod/vqmod ) because vQmod doesn't support installing via composer itself.
17+ 2 . ` composer require burdapraha/oc_version_number dev-master `
18+ 3 . ` composer require sasedev/composer-plugin-filecopier ` for files manipulating
19+ 4 . Add this code to your composer.json project file, extra section:
20+
21+ ```
22+ "extra": {
23+ "filescopier": [
24+ {
25+ "source": "vendor/burdapraha/oc_version_number/upload",
26+ "destination": "upload",
27+ "debug": "true"
28+ }
29+ ]
30+ }
31+ ```
32+
33+ It will move vQmod xml file to correct folder.
34+
35+ 5 . optionally you can add row to your ` .gitignore ` file with path to svg.xml (example: upload/vqmod/xml/oc_version_number.xml)
36+ 6 . celebrate!
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " burdapraha/oc_version_number" ,
3+ "description" : " Helper function which fixing visitors browser cache issue after your changes at CSS or javascript" ,
4+ "type" : " vqmod-plugin" ,
5+ "license" : " MIT" ,
6+ "authors" : [
7+ {
8+ "name" : " Michal Landsman" ,
9+ "email" : " landsman@insuit.cz"
10+ }
11+ ],
12+ "require" : {}
13+ }
Original file line number Diff line number Diff line change 1+ <modification >
2+ <id >Version number for styles - cache issue</id >
3+ <version >1.0.0</version >
4+ <vqmver >2.1.5</vqmver >
5+ <author >Michal Landsman</author >
6+
7+ <!-- add new function to the system helper -->
8+ <file name =" system/helper/general.php" >
9+ <operation info =" version number" >
10+ <search position =" after" ><![CDATA[ <?php]]> </search >
11+ <add >
12+ <![CDATA[
13+ if(!function_exists('versionNumber')){
14+ function versionNumber($path) {
15+
16+ $absolutePath = DIR_APPLICATION . $path;
17+ $clearPath = str_replace("catalog/catalog/", "catalog/", $absolutePath);
18+ $version = file_exists($clearPath) ? filectime($clearPath) : 'ERROR_FILE_NOT_EXIST!';
19+ return "{$path}?v={$version}";
20+ }
21+ }
22+ ]]>
23+ </add >
24+ </operation >
25+ </file >
26+
27+ <!-- replace styles calling with path contains version number, you can use this function for your another files in your theme ... -->
28+ <file path =" catalog/view/theme/*/template/common/" name =" header.tpl" >
29+ <operation >
30+ <search position =" replace" ><![CDATA[ <link href="<?php echo $style['href']; ?>" type="text/css" rel="<?php echo $style['rel']; ?>" media="<?php echo $style['media']; ?>" />]]> </search >
31+ <add ><![CDATA[ <link href="<?php echo versionNumber($style['href']); ?>" type="text/css" rel="<?php echo $style['rel']; ?>" media="<?php echo $style['media']; ?>" />]]> </add >
32+ </operation >
33+ </file >
34+
35+ </modification >
You can’t perform that action at this time.
0 commit comments