By dariomem on
Hi All,
Hope this finds you all well! I need to have different background CSS for different pages in Drupal 6. I know how to do this for the front page;
<?php if ($is_front) : print " id=\"front\""; endif;?>
and then I add a body#front for the front page css.....
but let us assume I want to change the CSS for a "About us" Page? How would I do it? I tried to use the same logic but it doesn't appear to work.... so:
<?php if ($is_aboutus) : print " id=\"aboutus\""; endif;?>
Any suggestions or work around would be highly appreciated!
Kind Regards,
DM
Comments
...
$is_front is the only such variable that Drupal populates. It does, however, populate $node->nid when viewing a node, so try this in your page.tpl.php:
if ($node->nid) : print " id=\"node-" . $node->nid . "\""; endif;_
You can see the template.php file for the fusion theme (around line 50), for an example of how to setup body classes.
Different Body CSS for different pages?
Hi,
I was just looking to do this too. Dariomem I can't get your example to work.
I have tried putting...
if ($is_front) : print " id=\"front\""; endif;into my page.tpl.php
My first problem is it seems to actually print "id="front"" onto the page.
The second problem is I am not sure how body#front is working in the css.
I have tried the line
body#front #container {background: url("about.jpg")};
But its not working.
Any tips would be greatly appreciated.
Many thanks
Simon
_
I don't understand-- it's printing
id="front"because that's exactly what you're telling it to print..
Ah yeah. I am a bit dumb. I guess my problem is more in implementing the body#front within my style sheet. I thought the print id="front" was to store the id state.
Thanks for your reply
Simon
_
ah ok, then what exactly does "not working" mean? Where is the image located? The body#front line looks correct on the surface, but there's really no way to know for sure without more details.
...
do you actually place this piece of code directly behind body? like:
.
Hey thanks for this help.
so in page.tpl.php I have;
Then in style.css
The image drupal_interface1.png is there right next to the other but does not appear on the front page.
Many thanks
Simon
...
if that is exactly what you have in your style.css, then you should look at the position of the closing brackets and semicolon of your body#front
Try refreshing your
Try refreshing your cache
hold down shift and click on your browsers refresh button on a mac
hold down control and press f5 on a pc
thanks
It seems to work now.
I think I just messed up my styles.... I did not need #container (I had taken that from another post)
This is the working css.
Thanks Simon