CSS edits on a live site

Recently I had cause to recode some CSS on a live textpattern site. With any CSS re-working there’s the inevitability of trying different methods to get things looking just right. Not the thing to be doing on a live site so here’s a plugin-free trick that might help.

It’s very simple. In Textpattern (or any CMS for that matter) I usually have one line calling the CSS for the site.

<txp:css format="link" n="default" />

But for this new work I’d really like textpattern to ignore me completely and serve my new CSS file. I can do this based on my location. Using whatismyip.com I can figure out my IP address eg:

Using the following PHP code I can get textpattern to serve that new CSS file instead of the default current style sheet.

echo "<txp:css format=\"link\" n=\"new_css_file\" />";
else {
echo "<txp:css format=\"link\" n=\"default\" />";
comments powered by Disqus