2 replies [Last post]
Last seen: 19 years 2 weeks ago
Joined: 2004-01-13
Posts: 5
Points: 0

I have a header.inc file and a footer.inc file that is called to each new file that I create.

The header.inc file holds all the javascripts as well as calls the css, etc. It also begins the body and the footer.inc file closes the body. In other words in each new file that I create I have a php statement calling the header, and at the bottom of the file another statement that calls the footer. So each new file is really only part of the body as the title and head are found in the header.inc file.

What I would like to do is be able to change the background color of the body of a new file if I choose to do so. But obviously because each new file is only part of the body I cannot put a css style in the new file.

Is there any way of writing a php statement that I can place in a new file that would allow me to change the background-color of let's say #faunabody for that particular page??.

Hope this is clear...thanks alot

Last seen: 19 years 19 weeks ago
Joined: 2003-09-19
Posts: 3
Points: 0

writing a php statement to change a css style

well you seem to be going through alot more work than you need to but...

CSS has built in style switching capabilities:


<title>look at me I am a Title!</title>
<link rel="stylesheet" type="text/css" title="default" href="default.css" />
<link rel="stylesheet" type="text/css" title="other" href="other.css" />
<link rel="stylesheet" type="text/css" title="otherother" href="otherother.css"  />

<script type="text/javascript" src="styleswitcher.js"></script>

<a href="#" onclick="setActiveStyleSheet('default'); return false;">Default Style</a>
<a href="#" onclick="setActiveStyleSheet('other'); return false;">other Style</a>
<a href="#" onclick="setActiveStyleSheet('otherother'); return false;">otherother Style</a>

with css one could make multiple css styles and then call them in through javascript which can be found here http://www.alistapart.com/d/alternate/styleswitcher.js

I just found this (on the same website) that appears to do the same thing with php http://www.alistapart.com/articles/phpswitch/

of course you could do this all by calling in a random number gen and then using a line write to replace a value for bgcolor.

maybe I am missing what you are attempting to do

Last seen: 18 years 43 weeks ago
Joined: 2004-03-29
Posts: 11
Points: 0

writing a php statement to change a css style

Burn is right here is another useful link from the same group of people who are down with ala, over at stopdesign.com.


It goes through it step by step and I believe will answer your question.