简体   繁体   中英

My Joomla Template is loading my custom CSS using JS. Is there a way to add the unique version tag to my custom CSS? i.e: custom.css?20180101

I normally just add my unique tag to the css path in the section of my html, but my template is adding my custom CSS via Javascript:

if (is_file(T3_TEMPLATE_PATH . '/css/custom.css')) {
$this->addStyleSheet(T3_TEMPLATE_URL . '/css/custom.css');
}

I tried adding the unique tag to the above, but it doesn't work:

if (is_file(T3_TEMPLATE_PATH . '/css/custom.css')) {
$this->addStyleSheet(T3_TEMPLATE_URL . '/css/custom.css?20180101');
}

I inspected my web page and it still spits out:

<link rel="stylesheet" type="text/css" href=".../css/custom.css">

The above code again works stored cache for same file name, but you want each page request new file name randomly,so you can use the below code was perfectly suite for you.

if (is_file(T3_TEMPLATE_PATH . '/css/custom.css')) {
   $this->addStyleSheet(T3_TEMPLATE_URL . '/css/custom.css?'.rand());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM