hi everyone,
our layout (based on the yahoo grids.css system) looks like this:
header
navSidebar mainContent
footer
the mainContent div tag needs to have a background-image that can be changed depending on the page. i'd like to have the image specified using the theme, so that our content manager can decide which background-image to use without me having to change any code. the theme i'm using was derived from the standard bluemarine theme. basically i stripped out everything excpept the print $content; section and replaced it with my own code, but the admin side is still bluemarine.
i know i can hard-code some php code to dynamically generate the background-image portion of the css file, but i'd rather avoid this, because every time we want to add a new image i'd have to change the php code.
thanks so much!!!
Comments
would i be able to
would i be able to accomplish this using some sort of taxonomy?
like i can label a page "image1" and have a script automatically make any page that has "image1" as a label use image1.jpg as the background-image in the
i'm super new to drupal, so the whole taxonomy, blocks, modules, books, pages, etc thing is still kinda hazy.
Try this code
I use the following that I found somewhere in these forums:
Put this code in page.tpl.php before your doctype definition i.e. this must appear first on the page. Then modify your body tag:
Now each page will have an id based on its path. This allows you to then define unique styles on a per page basis. So, in your example, you could do something like this in your css file:
All you have to do to change the image at a later stage is replace about.jpg or contact.jpg with a new image. If you don't want an image, delete the file - if the css can't find the image, it ignores it.
______________________________________________________________________________________________________
Recent Drupal websites: http://mbacasecomp.com and http://hudsonhistoricalsociety.ca
______________________________________________________________________________________________________
very interesting...do you
very interesting...do you think this would work using the page's taxonomy term instead of the path?
that way any page that's tagged "page-contact" by the content manager would have contact.jpg as the image.
this would allow the content managers to decide which image they want on a given page, just by changing the taxonomy term.
this way, they can go to town changing images without having to involve me = less work for me!!!
am i on the right path?
Might work, but...
You could try something like this:
and leave out that first bit of code I posted earlier. However, if you have more than one term for a page, you're probably going to have problems. I haven't tried this myself, but its worth a go I guess.
______________________________________________________________________________________________________
Recent Drupal websites: http://mbacasecomp.com and http://hudsonhistoricalsociety.ca
______________________________________________________________________________________________________
Than you for this --- Daily
Than you for this
---
Daily webmaster news and directory (digg style)
http://www.dwebmaster.com
Is it possible to use the same logic to control images?
Sorry if I am asking in the wrong place, but this was the closest topic related to what I need.
The thing is I need that my banner image changes depending on the page I am browsing, like for example, my blog page has a photo of me, and my girlfriends blog has a picture of her. I am talking about a "top picture" element that I know where it is in the style.css file.
Thanks for your help and ask more info if I was unclear.
Wonderful tip! Thank you!
themacgeek
It Ain't Easy Being A Geek
http://themacgeek.com
--
Jamie Meredith