<Debug live site with local css file - WebCastle

Our services can execute your Digital Marketing Strategies

28

Monday

Nov 2011

Debug live site with local css file

For developers who work with CMS websites, you might need to make some changes on the site once the site has gone live. But you want to see if making changes in the CMS cause any issues with existing website. In general case, you might have all the live content and images on your dev server. But when its the case of Client managed CMS, you might not always have the latest content data with your dev server. So here is a work around, you can switch live site css file with any other (dev server css) you want. All you need to do is, pass your dev css url as a url parameter. www.livesite.com/?css=http://localhost/myproject/style.css - This will load style.css from your local server. How to do that ? Its ptety basic self explanatory php code as below.

<?php
function putStyle() {
  if(isset($_GET["css"])) {
  print(' <link rel="stylesheet" href="'.$_GET["css"].'" /> '); // loads value of parameter css 
  }
  else {
  print ('<link rel="stylesheet" href="css/style.css" />'); // change to your default css
  }
  };
putStyle();
?>
Now, instead of using link tag to add style file, you just need to paste the above code or include the file which has above code. See the screenshot to know what I mean. So this is how we do work on the live sites with real time site updates. Tell us how you do that in comments.

Posted by Webcastle