HighDots Forums  

Host-sensitive style sheet

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Host-sensitive style sheet in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steve Swift
 
Posts: n/a

Default Host-sensitive style sheet - 09-05-2008 , 02:29 AM






I have a pair of webservers (actually virtual hosts in the same apache).
They are mostly clones, but one is used to develop changes, so is the
test system.

Most of the pages are generated by CGI scripts, and on the test system
the header incorporates <BODY BGCOLOR=#FFD0D0> generating a puce
background which warns people of the test environment.

I can easily change this to inline CSS, but I'd prefer to use an
external stylesheet. I could use different stylesheets for the test and
production systems (and probably will, so I can test the effects of
changes in the stylesheet itself) but I started to wonder if there were
any way within CSS of setting the background colour based on the host.

One great advantage of a stylesheet which is sensitive to the host is
that it would solve the problem of having static HTML pages which
changed their background colour based on which host was being used.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk

Reply With Quote
  #2  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: Host-sensitive style sheet - 09-05-2008 , 07:17 AM






Steve Swift wrote:
Quote:
I have a pair of webservers (actually virtual hosts in the same apache).
They are mostly clones, but one is used to develop changes, so is the
test system.

Most of the pages are generated by CGI scripts, and on the test system
the header incorporates <BODY BGCOLOR=#FFD0D0> generating a puce
background which warns people of the test environment.

I can easily change this to inline CSS, but I'd prefer to use an
external stylesheet. I could use different stylesheets for the test and
production systems (and probably will, so I can test the effects of
changes in the stylesheet itself) but I started to wonder if there were
any way within CSS of setting the background colour based on the host.
No. But you can create segregate the difference off into a separate pair
of files named, say, bodybg.css, one on the test server containing only

body { background-color: #ffd0d0; }

and one on the production server containing only

body { background-color: #ffffff; }

Then, in your main CSS file, remove the rule that sets the background
color, and include

@import "bodybg.css";

at the top.


Reply With Quote
  #3  
Old   
Jonathan N. Little
 
Posts: n/a

Default Re: Host-sensitive style sheet - 09-05-2008 , 10:47 AM



Steve Swift wrote:
Quote:
I have a pair of webservers (actually virtual hosts in the same apache).
They are mostly clones, but one is used to develop changes, so is the
test system.

Most of the pages are generated by CGI scripts, and on the test system
the header incorporates <BODY BGCOLOR=#FFD0D0> generating a puce
background which warns people of the test environment.

I can easily change this to inline CSS, but I'd prefer to use an
external stylesheet. I could use different stylesheets for the test and
production systems (and probably will, so I can test the effects of
changes in the stylesheet itself) but I started to wonder if there were
any way within CSS of setting the background colour based on the host.

One great advantage of a stylesheet which is sensitive to the host is
that it would solve the problem of having static HTML pages which
changed their background colour based on which host was being used.

Perl:

use CGI;

sub localMode
{
$localServerName=shift;
if( $ENV{SERVER_NAME} eq !localServerName)
{
return(
style({-type=>'text/css'},'body { background-color: #ffd0d0; }')
);
}
else
{
return('');
}
}


PHP

function localMode($localServerName)
{
if($_SERVER['SERVER_NAME' == $localServerName)
{
return '<style type="text/css">body { background-color:
#ffd0d0;</style>';
}
else
return '';
}
}

Just place function AFTER the last STYLE link.


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.