I know this is more of a theming inquiry, but the theme I'm using isn't widely distributed and I wanted to expand the pool of knowledge to solve this. Right now, I have a two page backgrounds, one for the main page and one for content pages. It is pulled like so in my page.tpl.php:
<?php if($is_front): ?>
<img id="main-image" src="<?php print $base_path . $directory; ?>/images/home-bg.jpg" alt="<?php print $site_name; ?>" />
<?php else: ?>
<img id="content-image" src="<?php print $base_path . $directory; ?>/images/content-bg.jpg" alt="<?php print $site_name; ?>" />
<?php endif; ?>
What I would like to do, if it is possible, is create a field called field_bgimage assign it to all content types. Then have the page.tpl.php file check the current node to see if the field_bgimage is populated and if so, display that image as the page background instead of the two fallback images currently reflected in the code above. Is it even possible to have the page template pull and use a node's field?
Comments
Comment #1
Gilles G. commentedHello SuperRookie,
I've the same question on my post today : http://drupal.org/node/1260426. Any idea ?
:)
Comment #2
SuperRookie commentedOkay, I got this working with the help of a few other people. With the following in my page preprocess:
And this in my page template where it calls the background images:
It returns the main page image if it's on the main page, and then the content's bgimage field as the bg unless none is provided, then it falls back on content-bg. Works perfectly!
SR
Comment #3
dddave commented"Time" seems to have fixed this. Closing old, stale issues. If the issue still persists feel free to re-open.