Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2005-11-21 23:16:25

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Use one template for multiple sections

> doggiez wrote:

They don’t need a separate page template, though it can be preferable if you have different styles for those sections. But even then you could solve that by doing something like this:
<code>
<txp:if_section name=“section1”>
<div id=“section1”>
</txp:if_section>
<txp:if_section name=“section2”>
<div id=“section2”>
</txp:if_section>
<txp:if_section section=“section1”>
content for section1
</txp:if_section>
<txp:if_section section=“section2”>
content for section2
</txp:if_section>
</div>
</code>

I know this is an old thread, but just want to say that the code suggested by doggiez can be replaced by a simple line:

<div id="<txp:section />">


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2005-11-22 03:56:42

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: Use one template for multiple sections

Whoa,
Maniqui! I never thought of that! Hmm. Smarter and smarter. Reading the forums regularly is like drinking a good beer. Sure it kills brain cells, but it kills off the weak ones so I get smarter and smarter. :)

Matthew


Offline

#15 2005-11-22 04:54:43

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Use one template for multiple sections

I like your thinking there Matthew

throwing section names into your body ID and/or class is another way of transforming layouts based on what section you’re in, without using different page templates

Offline

#16 2005-11-22 06:25:21

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Use one template for multiple sections

Well it’s an excellent idea if someone has used it, or is it still theory?


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#17 2005-11-22 07:03:08

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Use one template for multiple sections

> thebombsite wrote:

> Well it’s an excellent idea if someone has used it, or is it still theory?

Stuart, do you mean if someone has used <div id="<txp:section />">?

I have used it sometimes in <body id="<txp:section />"> (long time ago, in the days of RC1, to achieve a way to style the current section link in the main menu).

Another interesting place to put it is in a “div” surrounding your article layout.
I mean:

<div class="article <txp:section />">
<h3><txp:title /></h3>
more article tags
blablab
</div>

This way, you can give unique styles to your articles, depending on the section it belongs to.

Last edited by maniqui (2005-11-22 14:30:37)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#18 2005-11-22 07:32:08

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Use one template for multiple sections

I was just wondering if it had actually been tried and works. If you’ve used it then great! Go to the top of the class! :)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#19 2005-11-22 08:28:58

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Use one template for multiple sections

for sure stuart … it’s become a habit to throw the section name as an id into the body tag, so you can override styles for specific sections (e.g. contact forms vs navigation pulldowns)

also u can change widths on divs depending on the section … very handy if you have some sections with one column, some with two, some with three, etc : )

Offline

Board footer

Powered by FluxBB