Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-05-14 05:00:26

darock
Member
Registered: 2007-11-23
Posts: 54

how to show different background for a div when visiting a new section

I want a different background image to show for a div on my website whenever a user visits a new section of the site. For example, if they visit section A, then I would want a certain background-image pulled from the css to appear. And then section B would have another background image for that div, etc… How do I do this?

Offline

#2 2009-05-14 07:28:33

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: how to show different background for a div when visiting a new section

You could use this:

<div class="section_<txp:section title="0" link="0"/>"></div>

And add this to CSS:

div.section_SECTIONname {background: url(lalala.jpg);}

Or, instead of applying custom class to div you can dirrectly set background image:

<div style="background: url(section_<txp:section title="0" link="0"/>.jpg);"></div>

And don’t forget to upload img section_SECTIONname.jpg to your server.


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#3 2009-05-14 08:36:05

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: how to show different background for a div when visiting a new section

I usually create an id or class at the body level:

<body id="section_<txp:section title="0" link="0"/>">

So you can apply different css styles without the need to apply this technique in different subelements. Example css:

#section_one h1 {color: red}
#section_one .thediv {background-color: red}
#section_two h1 {color: blue}
#section_two .thediv {background-color: blue}

Offline

#4 2009-05-14 11:25:12

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: how to show different background for a div when visiting a new section

Might be worth pointing out that by default, the section tag title and link attributes are set to “0”…

Offline

#5 2009-05-14 12:42:12

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: how to show different background for a div when visiting a new section

jstubbs wrote:

Might be worth pointing out that by default, the section tag title and link attributes are set to “0”…

Textbook says this attrs will be set to "1" from Crockery (4.1), though it’s better to be ready

Last edited by the_ghost (2009-05-14 12:45:59)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

Board footer

Powered by FluxBB