Textpattern tips, tutorials and code snippets

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\" />";

4 Comments Comment feed

You could also use the superb rvm_privileged plugin:

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

Then you don’t need to find out your own IP adress and you don’t have to change it in case the IP has changed.

I use Firefox add-ons firebug or web developer to play around with live sites :-)

@marcus Or course! I totally overlooked Ruud’s plugin. Thanks.

Actually, I think this is a neat method to serve different content and different styles to IP addresses from different regions.


Add a comment

Use Textile help to style your comments