Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
how to use section title in page templates.
EDIT: the following has become obsolete in TXP 4.0.2. Now, you can use <code><txp:section title=“1” /></code> in page templates to display the section title.
But keep reading this thread, maybe you find some useful information here.
<hr size=1 />
With the inminent arrive of TXP version 4.0.2, the following technique should become obsolete (please, can anyone confirm this?)… or not?
Surely, most of us have felt the sadness for the limitations of <code><txp:s /></code> to show section titles and for the impossibiliy of using <code><txp:section /></code> in a page template context.
I would be that the following techniques is one of these workarounds that nearly can make a plug-in become obsolete (no, not really, mary’s plug-in is powerful).
But I also must admit that this kind of techniques doesnt make me feel comfortable when I use it (I dont know why).
Finally: I post this as an example of how to use some built-in tags and their attributes and also to show the flexibility of TXP: you can achieve something by combining some built-in tags, until the developers “charge their batteries” and release this as a built-in functionality.
So, this is it:
- Put this in your page template where you want to show your section title.<br /> <code><txp:if_section name=”“> <txp:else /> <h1><txp:article form=“section_title” limit=“1” /></h1> </txp:if_section></code><br /> This is like saying to TXP: “if default section, dont show anything, else, show the form ‘section_title’ wrapped by ‘h1’”.
- Create the ‘section_title’ form with only this code inside<br /> <code><txp:section title=“1” /></code>
- Listo!
- this wont work if the section is empty (= if no articles has been saved in the section)
- you have to set <code>limit=“1”</code> to only show the section title just once. If not, it will output the section title once per each article that is showed in the page.
Conclusion:
This may become obsolete maybe this week (if 4.0.2 becomes available for those like me that doesnt know what SVN stands for).
But I have searched this technique in the forum and I could not find anything similar. I know this one would be very useful few months ago. Or maybe not. I dont know.
And again: the intention of this technique is to show how to think parallel in TXP (wow, parallel thinking in TXP)
Offline
#2 2005-11-01 05:12:35
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: how to use section title in page templates.
yes, good tip – and occasionally use that technique to pull in a category title too (can’t remember the circumstance)
would be excellent if <txp:c />
and <txp:s />
could show either name or title …
Offline
Re: how to use section title in page templates.
That will be sorted in 4.0.2. Both <code><txp:section title=“1” /></code> and <code><txp:category title=“1” /></code> work in page templates. The only exception would be the default section where your method would be handy if anyone wants to give it some kind of title, though a simple title within the h1 would do it. No need for a form in this case.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline