icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.
Old August 10th, 2004, 11:19 PM   #1 (permalink)
Registered User
On a golden path...
 
Joined in May 2004
332 posts
Gave thanks: 0
Thanked 0 times
Style Switching

I don't know if this is possible but here Is what id like to accomplish. I have googled it and been unsuccessful.

I have php includes, and I want to have it change to a red layout when it changes to something chiefs related (some table cells bg color from blue to red). How do I accomplish this, if possible?
__________________
www.anything4free.com (Not my site but if you want free stuff (ipods, flatscreens etc) go there.)
KCAA is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 10th, 2004, 11:23 PM   #2 (permalink)
Hostering?
Excelling Contributor
 
mobius's Avatar
 
Joined in Jan 2004
Lives in New York
Hosted on D41
970 posts
Gave thanks: 0
Thanked 0 times
You could use alternative style sheets and have a javascript switch them. I've seen it done.
__________________
{_DIME.41 Reseller_}

Stay cool.

>> Avatar used with permission from garyzullo.com <<
mobius is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 2:28 AM   #3 (permalink)
Surpass Fan
Seasoned Poster
 
Joined in Aug 2004
Lives in North Carolina, USA
Hosted on Pass11
46 posts
Gave thanks: 0
Thanked 0 times
I'd prefer to do it in PHP.

I checked out your site's HTML source. First, I'd advise using external stylesheets (CSS in a seperate file) and link it to the page by putting this in your HTML HEAD section:
Code:
<link rel="stylesheet" href="/path/to/stylename.css" type="text/css">
Then it seems like it would be pretty simple to check the $folder or $access variables to determine what stylesheet you want, and set the path/filename of that stylesheet to another variable, such as $stylesheet. For example:
PHP Code:
//determining which stylesheet to show
if ( $folder == "chiefs" )
  
$stylesheet "path/to/chiefstyle.css";
else
  
$stylesheet "path/to/defaultstyle.css";

//printing the meta link to the stylesheet
echo "<link rel=\"stylesheet\" href=\"$stylesheet\" type=\"text/css\">"
Using this method, you would be controlling the style of every page via the main script that includes everything. Just have that snippet of PHP near the top, inside the page's <head> (or just at the top like the <style> is now). (btw, the source code is a little out of order. I guess it's due mostly to the inclusion process.)

Hope that helps!
The Javascript thing mobius mentioned would probably also work, but I know PHP, not Javascript.
__________________
All your base are belong to us.

Last edited by AngryPeasant; August 12th, 2004 at 2:31 AM.. Reason: typo in code snippet
AngryPeasant is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 8:51 AM   #4 (permalink)
minor deity
Super #1
 
Bigjohn's Avatar
 
Joined in Apr 2004
Lives in Georgia
Hosted on XEON
7,395 posts
Gave thanks: 28
Thanked 94 times
Right!

My 'index' page is just a bunch of includes. It would not be too difficult to include a different 'head.inc' within the conditionals....

PHP Code:
<?php
require 'head.inc';
if (isset(
$_GET['class'])) {
$class="";    
}
if (!isset(
$_GET['page'])) {$content'page1.inc';}
else {
$content$_GET['page'].'.inc'$class="tc";}
include 
'containers.inc';


include 
$content;
include 
'footer.inc';
?>
The above is my entire index.php...

You could easily modify that to build a $head variable based on the requested page too... if you follow. You just then have to move the 'require head.inc' down into the conditional loop.

John
__________________
Proud to be a Surmunity Mod!
XEON PASS60 PASS61
Make a fundamental difference!
My Sites:
Curious about Brewing Beer? Join the community!
>>>>> Some Change is GOOD! Keep your paycheck! Support the Fair Tax
Get into an Art museum
Victorian London
It's your brain -ON WEB - mybrainhost.com (under development)
What SHOULD Government do? Much Less than it Does!
Bigjohn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 11:54 AM   #5 (permalink)
Registered User
On a golden path...
 
Joined in May 2004
332 posts
Gave thanks: 0
Thanked 0 times
Okay, i see what your doing. I got the location.

What should i put in the table cells and style sheet so they change when i want them to. For example, the default is certain cells are blue. When chiefs is selected I want them to turn red using this css. How do i do that?

Just curious what do you mean out of order?

And i also assume that if I want to add another option to change the style sheet, I could by adding an else if?
__________________
www.anything4free.com (Not my site but if you want free stuff (ipods, flatscreens etc) go there.)
KCAA is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 2:32 PM   #6 (permalink)
Registered User
On a golden path...
 
Joined in May 2004
332 posts
Gave thanks: 0
Thanked 0 times
I just can't get it to work (the style sheets themselves)
__________________
www.anything4free.com (Not my site but if you want free stuff (ipods, flatscreens etc) go there.)
KCAA is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 2:35 PM   #7 (permalink)
minor deity
Super #1
 
Bigjohn's Avatar
 
Joined in Apr 2004
Lives in Georgia
Hosted on XEON
7,395 posts
Gave thanks: 28
Thanked 94 times
Post a link to your style sheet and a snip of the html that you want styled.
__________________
Proud to be a Surmunity Mod!
XEON PASS60 PASS61
Make a fundamental difference!
My Sites:
Curious about Brewing Beer? Join the community!
>>>>> Some Change is GOOD! Keep your paycheck! Support the Fair Tax
Get into an Art museum
Victorian London
It's your brain -ON WEB - mybrainhost.com (under development)
What SHOULD Government do? Much Less than it Does!
Bigjohn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 3:03 PM   #8 (permalink)
Registered User
On a golden path...
 
Joined in May 2004
332 posts
Gave thanks: 0
Thanked 0 times
Quote:
Originally Posted by Bigjohn
Post a link to your style sheet and a snip of the html that you want styled.
I got it. Theres a problem in here code.

Should be this:
Quote:
//printing the meta link to the stylesheet
echo "<link href=\"$stylesheet\" rel=\"stylesheet\" type=\"text/css\">";
Not:
Quote:
//printing the meta link to the stylesheet
echo "<link rel=\"stylesheet\" src=\"$stylesheet\" type=\"text/css\">";
Thanks anyway, and my other question still stands, if i want to add something i assume i use else if
__________________
www.anything4free.com (Not my site but if you want free stuff (ipods, flatscreens etc) go there.)
KCAA is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 11th, 2004, 3:05 PM   #9 (permalink)
Surpass Fan
Seasoned Poster
 
Joined in Aug 2004
Lives in North Carolina, USA
Hosted on Pass11
46 posts
Gave thanks: 0
Thanked 0 times
Quote:
Originally Posted by KCALLACCESS.com
What should i put in the table cells and style sheet so they change when i want them to. For example, the default is certain cells are blue. When chiefs is selected I want them to turn red using this css. How do i do that?
Give the appropriate cells of the table a style class name like <td class="tableborder"> instead of setting their color via local HTML like <td bgcolor="000099">.

Then in your stylesheet files make another style rule for ".tableborder" like this:

.tableborder { background-color:#000099; }

Then, depending on which stylesheet is used for the page, ".tableborder" could mean blue, red, or whatever other color is present in the stylesheet.

Quote:
Just curious what do you mean out of order?
I just mean that it violates the structure that an HTML document is supposed to have (talking about the HTML source). The basic structure should look like this:
<html>
<head>
<!-- meta tags, stylesheets, title, etc -->
</head>
<body>
<!-- all page content -->
</body>
</html>

It's wierd that what you have works, because there's multiple head, body, and html tags. But since it does actually work, it's a secondary issue. If you have the time it'd probably be a good idea to clean it up a little. (so that when people like me invade your source, we can't complain)

Quote:
And i also assume that if I want to add another option to change the style sheet, I could by adding an else if?
That's correct.
__________________
All your base are belong to us.
AngryPeasant is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On