XF 2.2 How to implement cachebusting / versioning for an external file called within a template

bzcomputers

Well-known member
At times I call external .css and .js within templates. I would like to able to use XenForo's built in cache busting for this. Without referencing PHP filemtime directly within a template what is the best way to go about this?

Sample css reference within template:

Code:
<link rel="stylesheet" href="https://www.mysite.com/styles/custom.css" type="text/css" />
 
You could maybe append ?_v={{ $xf.style.getLastModified() }} or ?_v={{ $xf.options.jsLastUpdate }}, but I'd honestly recommend just creating a custom.css template for it and then including it via:

HTML:
<xf:css src="custom.css" />
 
Back
Top Bottom