Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Different background image on each page
I want to be able to pick a unique image to display as background image on different pages.
Is that possible? I’m looking at the bas_img_selector, but I’m not sure if it’ll do the trick because I want it implemented as BG image?
(http://textpattern.org/plugins/330/basimgselector)
Right know the BG image is the same for all pages because it’s in my CSS {body}.
What to do?
Offline
Offline
#3 2005-12-14 22:04:38
- Neko
- Member
- Registered: 2004-03-18
- Posts: 458
Re: Different background image on each page
Check out also this thread.
Offline
#4 2005-12-14 22:14:29
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Different background image on each page
I’m doing it this way (using one page template for all sections):
<code>
<txp:if_section name=“section1”>
<div id=“content1”>
</txp:if_section>
<txp:if_section name=“section2”>
<div id=“content2”>
</txp:if_section>
your content
</div>
</code>
Set the background images for #content1, #content2 etc. in your CSS.
Offline
#5 2005-12-14 23:14:51
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Different background image on each page
if you want to change background by section, you could put in your page template <body id="txp:section /">
then in your css, set up the rules per section, e.g.
body#about {background:#ddd url(/images/3.jpg) no-repeat;}
body#contact {background:#ddd url(/images/4.jpg) no-repeat;}
this is what zero suggested above;
you could also use conditionals a la doggiez to fine-tune… by having a few body tags with different hooks, each output according to if it’s a section, category list display, search results display, etc
Offline
Re: Different background image on each page
Nice – looks promising. But I have different pictures for each page. And – if possible – the ordinary user should be able to connect an image to a new page.
An alternative could be that I set up all the pictures for the current pages, and when ordinary user make new pages he gets a default picture which I picked.
Is that possible some-how?
Update:
I’ve use the section id on <body> which helped for my sections. But I also have a section with 7 different pages who need a unique image each? Can body-id be page names?
Last edited by gejl (2005-12-15 13:05:04)
Offline
#7 2005-12-15 23:22:29
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Different background image on each page
depends how you’ve set up your site… but could articles use a custom field to insert your background image?
throw a div around the whole page, and then in your page template:
<div class="wrapper" <txp:if_individual_article>style="background:#fff url(<txp:custom_1 />) no-repeat !important;"</txp:if_individual_article> >
bon chance! (dunno danish for ‘break a leg’)
Last edited by nardo (2005-12-15 23:24:18)
Offline
Re: Different background image on each page
Thanks.. I’m going for your solution “nardo”, but I have a few problems.
I included it this way in my template:
<code><div class=“wrapper” <txp:if_individual_article>style=“background: #fff url(/images/<txp:custom_field name=“billede” />.jpg) no-repeat right top;”</txp:if_individual_article>></code>
And this is my output on a specific article:
<code><div class=“wrapper” style=“background: #fff url(/images/.jpg) no-repeat right top;”></code>
In my first custom field (named “billede”) in this specific article I have the number “16”, which is referring to an image.
If I had an output from the custom-field I could debug, but this is strange? Right?
Last edited by gejl (2005-12-21 11:17:26)
Offline
#9 2005-12-21 23:07:49
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Different background image on each page
hi gejl, I think I led you a bit astray because I didn’t test first
try using an article tag that calls a specific form…
e.g.
<div class="wrapper" <txp:if_individual_article><txp:article form="page-bg" /></txp:if_individual_article> >
then, in the “page-bg” form:
style="background: #fff url(/images/<txp:custom_field name="billede" />.jpg) no-repeat right top;"
does that work?
Last edited by nardo (2005-12-21 23:08:47)
Offline
Re: Different background image on each page
nardo wrote:
<div class="wrapper" <txp:if_individual_article><txp:article form="page-bg" /></txp:if_individual_a...
nardo, I think you wanted to say:
<div class="wrapper" <txp:if_individual_article><txp:output form="page-bg" /></txp:if_individual_a...
Notice the txp:output in place of the txp:article tag.
But, please, forgive me if I’m wrong.
Last edited by maniqui (2005-12-22 04:38:30)
Offline
Re: Different background image on each page
Sorry, my mistake. Finally, I was wrong.
Now I understand why nardo is using txp:article:
inside the “page-bg” form, there is a txp:custom_field, and, that’s the reason. The custom field value is related to the individual article, so it needs to be called by an article form.
Offline
Re: Different background image on each page
nardo!
You’re the man – it’s working as it should!
Thank you very much..
Offline