Drupal implementing an advertising takeover with page background image I need to implement a background image advertising takeover that surrounds the page content in drupal. It's similar to the ones on ign (screenshot attached below).

The only ways I can think of seem really hacky, such as using a view block to display one result of a custom content type containing the image and showing the view in a custom region that spans the background of the page.

Can anyone think of a better way? It needs to be easy to set up in the CMS for an administrator and they need to be able to create different takeovers for different sections of the site.

Thanks
In your theme's preprocess_page() hook you could set a variable that is accessible in your page.tpl.php file.  Basically something like:

function YOURMODULE_preprocess_page(&amp;$vars) {

  $vars['background_image']=make_me_a_background_for_page($_GET['q']);

  // other page preprocessing goes here

}


where make_me_a_background_for_page() is a custom function that returns a path to an image based upon the page being viewed.  You can then use that variable however you want to create the background.

One way would be to put a quick div in the page somewhere like...

&lt;?php if (!empty($background_image)): ?&gt;
  &lt;div id="use-this-background-image"&gt;&lt;?php print $background_image; ?&gt;&lt;/div&gt;
&lt;?php endif; ?&gt;


and have it hidden in css:

#use-this-background-image {
  display: none;
}


and then use jQuery to set the body's background to it:

// Drupal Behaviors Wrapper here :)

  if ($('#use-this-background-image').length) {
    $('body').css('background-image','url("' + $('#use-this-background-image').text() + '")');
  }

// Drupal Behaviors Wrapper here :)


An added bonus of doing it in this somewhat convoluted way is the background image isn't loaded until after your page is, so it pops in after the content, which, to me at least, is nicer looking than watching a big background load and THEN the content.