Code Authors: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Code Authors Forum Index -> phpNuke Hints, Tips and Tweaks
Author Message
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 22, 2011 11:45 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

We know that forcing server side or browser caching of CSS is 'better' but we also know there are some unwanted side affects, like the cache not being updated instantly if you make changes to your CSS rules.

One simple way around this (in RavenNuke 2.4.x) is to add one line of code to the function addCSSToHead() in mainfile.php

Open mainfile.php and find the function around line 1913
Code:


function addCSSToHead($content, $type='file') {
      global $headCSS;

ADD AFTER
Code:


$content = ''.$content.'?'.filemtime($content).'';

The first three lines of the function should now look like this
Code:


function addCSSToHead($content, $type='file') {
      global $headCSS;
// G: versionise the file
       $content = ''.$content.'?'.filemtime($content).'';


What does this do?
Well, it takes the file name of the CSS file and appends a 'version' number to the file. The 'version' number is based on the files timestamp so if you make changes to your CSS file, the files timestamp changes and therefore, the version number changes also to force the new file name to be cached. The best way to see it in action is to view the source code for this site.

NB: Please note that if you are using one of my modules released in 2011 (CA Helpdesk and CA Testimonials and the updated Contact Plus) , any CSS files used in these modules will already have this type of functionality and will need a minor code change to prevent a conflict.
I have not tested for the scenario where CSS is used 'inline'

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
bestbuildpc
Suspended User



Joined: Jun 03, 2009
Posts: 61

PostPosted: Wed Feb 23, 2011 4:25 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

Thanks a lot for this little trick

Code:
/*

 * functions added to support dynamic and ordered loading of CSS and JS in <HEAD> and before </BODY>
 */
function addCSSToHead($content, $type='file') {
      global $headCSS;
// G: versionise the file
       $content = ''.$content.'?'.filemtime($content).'';
   // Duplicate external file?
   if (($type == 'file') and (count($headCSS)>0) and (in_array(array($type, $content), $headCSS))) return;
   $headCSS[] = array($type, $content);
   return;
}


I just did it and I can't see any conflict yet. Shocked
 
View user's profile Send private message
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Wed Feb 23, 2011 5:28 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

The conflict will only be seen on the index module pages for the modules listed in my post above.
I'm trying to get them updated now to remove that bit of code.

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
bestbuildpc
Suspended User



Joined: Jun 03, 2009
Posts: 61

PostPosted: Sun Feb 27, 2011 9:28 am Share on Linked InShare on FacebookShare on Twitter Reply with quote

Ok. Thanks, let me know when this is done to update it.
 
View user's profile Send private message
John Haywood
Newbie
Newbie



Joined: Jan 04, 2006
Posts: 3
Location: UK

PostPosted: Sun Feb 27, 2011 10:35 am Share on Linked InShare on FacebookShare on Twitter Reply with quote

A new version of Helpdesk will be available in the next few days - see Project Tracking center block.
 
View user's profile Send private message
bestbuildpc
Suspended User



Joined: Jun 03, 2009
Posts: 61

PostPosted: Sat Jul 28, 2012 2:36 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

I bought this module but it doesn't show to download on your shop area. Let me know when u arrive asap.
 
View user's profile Send private message
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Mon Aug 06, 2012 10:04 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

bestbuildpc wrote:
I bought this module but it doesn't show to download on your shop area. Let me know when u arrive asap.

Existing clients were given credits when we changed the Shop last year, so if you have not used those credits on different software, you should be able to purchase the software for free. At the final stage of purchasing, you should see that the actual charge is 0.00 if you have not used all your credits up.
If you have purchased this within the last 3 weeks and it isn't showing in the downloads area, let me know and I'll find an internet cafe so I can access the Shop and check it for you (the firewall here does not allow me to log in).

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Code Authors Forum Index -> phpNuke Hints, Tips and Tweaks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

 
Forums ©
linear-bunchlinear-bunchlinear-bunch
linear-bunch