Page Background
Permalink 1 user found helpful
Hi
Is it possible to set up an area whereby the user can upload an image to use as the page background for the ENTIRE theme?
I know how to do it for individual page types, but not for the whole theme.
Thanks
Luke
Is it possible to set up an area whereby the user can upload an image to use as the page background for the ENTIRE theme?
I know how to do it for individual page types, but not for the whole theme.
Thanks
Luke
Hi
Thanks for your suggestion. I'm a little concerned that it may not be the most elegant way to do it. I need the user to be able to update the site easily, even if they forget, and the scrapbook probably wouldn't be the first place they'd look. I just need something similar to the custom attribute. If not, I can just upload the same image to each page.
Is there any other way to do it?
Thanks.
Thanks for your suggestion. I'm a little concerned that it may not be the most elegant way to do it. I need the user to be able to update the site easily, even if they forget, and the scrapbook probably wouldn't be the first place they'd look. I just need something similar to the custom attribute. If not, I can just upload the same image to each page.
Is there any other way to do it?
Thanks.
Yes, there is a way it could be done. Add a background image as a page attribute, but instead of having it output in each page type, simply output the image into some CSS that's included in the header.php file.
Let me know if that helps. Obviously it would mean coding some stuff...
Let me know if that helps. Obviously it would mean coding some stuff...
I did something on a site where I had a default background image set in my stylesheet and then a background_image attribute of the type file/image.
This following code you would place instead of your opening <body> tag in your header.php of your theme. It looks to see if the page has the background_image attribute set and uses the image stored it in it as the background, otherwise it looks at the parent and uses its background if it has one. It won't recursively look up the tree, but it is useful if you want to theme sections of your site.
Alternatively If you change the first line in the else clause to:
You will fetch the home page instead. So a page would look to see if it has it's own background, then fall back to the one set on the home page.
It's a bit of a rough cut and paste, but it might give you something useful.
This following code you would place instead of your opening <body> tag in your header.php of your theme. It looks to see if the page has the background_image attribute set and uses the image stored it in it as the background, otherwise it looks at the parent and uses its background if it has one. It won't recursively look up the tree, but it is useful if you want to theme sections of your site.
<?php $backgroundpos = ''; $uinfo = new User(); if($uinfo->IsLoggedIn()){ $backgroundpos = 'background-position: center 48px; '; } $c = Page::getCurrentPage(); $background_tag = 'style="'.$backgroundpos.'"'; $background = $c->getCollectionAttributeValue('background_image'); if ($background) { $background_tag = 'style="'. $backgroundpos .' background-image: url(\''. $background->getVersion()->getRelativePath().'\')"'; } else { $parentPage = Page::getByID($c->getCollectionParentID()); $parentback = $parentPage->getCollectionAttributeValue('background_image'); if ($parentback) {
Viewing 15 lines of 20 lines. View entire code block.
Alternatively If you change the first line in the else clause to:
$parentPage = Page::getByID(HOME_CID);
You will fetch the home page instead. So a page would look to see if it has it's own background, then fall back to the one set on the home page.
It's a bit of a rough cut and paste, but it might give you something useful.
something similar to the way the 'My_Site_Name' works for the Site Title area.
just a thought...