Hello, I've been reading google posts and drupal discussions for the past 48 hours and haven't found anything that will help me with what I'm sure must be an easy fix, so I'd really appreciate some help on this. I'm trying to change the background image for a specific node (node 3 to be exact). I have already changed the background image for my site by adding

body {
background-image: url("http://www.alecegan.com/sites/default/files/imagepicker/1/background10.jpg");
background-position: 50% 50%;
background-repeat: no-repeat;
background-attachment:fixed;

}
#content {
position:relative;
z-index:1;
}

to the style.css file, but I want a different background image for node 3. Can anyone suggest a way to do this? I've been reading about adding a specific reference and messing with the page.tpl.php file as well, but have had no success in all the posts and modifications I've read. My site is www.alecegan.com, please check out the code, I'd appreciate any advice. Thanks!!

Comments

try this

in your page.tpl.php file place the following code directly after the 'print $styles' command

  <style type="text/css">
       <!--
             body {
                 background: url(<?php print mytheme_bgimage($node ); ?>) no-repeat;      
}
-->
</style>

and then in your template.php file:

function mytheme_bgimage ($node) {

    if($node->nid == 3)
    {
               return 'image1';
    }
    else
    {
               return 'image2';
    }

}

There are probably much better ways of doing this, Id be very interested in hearing from others

Switch node 3 to full HTML

Switch node 3 to full HTML and place the style in the content.

<style type="text/css">
<!--
body
    {
    background: url(....) no-repeat;     
    }
-->
</style>

When you want to change several pages or all the pages in a subdirectory, create a subtheme with the change then use one of the modules that changes theme by page or area. If your theme is example, create example-with-one-image-changed and add the style. One of the style change modules will let you write the rules for adding the subtheme to specific pages.

http://d-theme.com uses a module that lets you type in the theme for a node when you create the node then changes the page to the theme named in the content node.

Another approach

You can theme your pages individually if you can get drupal to write a body id or body class specific to the page.

To do this you can use the themer module (http://drupal.org/project/themer) to write classes based on the page url (alias).

Before you do this, enable clean urls and turn on the path module.
Now give your pages some real names.

Lets say node 3 gets called "mycoolpage"
Themer will write a body class for mycoolpage" that will be something like "mycoolpage"
This module can be configured to write a variety of body classes.

Now you can write up some css for mycoolpage. It will look something like this:

body.mycoolpage {

background-image:url("http://www.alecegan.com/sites/default/files/imagepicker/1/mycoolpage_bg.jpg");
background-position: 50% 50%;

background-repeat: no-repeat;

background-attachment:fixed;
}

This is a pretty flexible approach.

Sorry, guys !

Really sorry (by advance) for these questions, but despite numerous attempts, i must have missed something, and couldn't make this module work. I found no proper manual, and reading the readme file, as well as the many contributions over the internet didn't help.

What i'm trying to do is get a different background image in each node (in the content area).

Working from the previous message, with a fresh D6 install, Garland theme selected as default and active (could be another one, default or custom theme either), path and themer module installed and activated (as clean urls are), several questions occur :

- where do i copy the code presented in the readme file of themer module () ? Yes, i know it seems to be in the page.tpl.php file, but inside the body tag, aside... ? What does it look like after the copy has been made ?

- the node name in the example is "mycoolpage" : is it the "Title" of the node, or the "alternative URL", or else ?

- writing up some css for "mycoolpage" : has this to be done in a new file called "mycoolpage.css", copied into style.css, or else ?

No need to tell you i've tried these different options, but couldn't make it. Once again, i must have missed something...

Maybe someone can help ? This would be fine. Thanks to anyone who does...

This is the relevant bit from

This is the relevant bit from the themer module read me:

NOTE: body class functionality requires the following change in your page.tpl.php
Add "print themer_body_class();" to your body tag class attribute:
<body class="<?php print themer_body_class(); ?>">

This is the unmodified body tag from the Zen theme:
<body class="<?php print $body_classes; ?>">

This is what it will look like with the addition of the themer code:
<body class="<?php print $body_classes; ?> <?php print themer_body_class(); ?>">

When you have put this in. You need to go to the themer config screen and tell it what tags to write in. You have a lot of options. What you need to do is get it to write in page specific body classes based on the page url.

Then you write up your css using the newly minted body class.

This is an example of the output from the themer module:
<body class="page-member-map no-sidebars path-member-map role-authenticated-user role-site-architect" >

"page-member-map" and "path-member-map" are both page specific body classes and can be used for your purpose,

Hope this helps.

a late answer !

Thank you very much for your answer.

Work has been keeping me far from this issue for a few days !...

I will try this and keep you informed...
Thanx again !

Helped me too.

Thanks!

nobody click here