Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-10-08 19:10:20
- Ian Goldby
- Archived Plugin Author
- Registered: 2007-09-16
- Posts: 6
Best way to put article excerpt in sidebar?
In a Textpattern site that contains many sections, each with its own (different) page template, I have a form template that outputs the sidebar, which is the same for each section.
One of the things I want to display in this sidebar is a title and picture for the latest article of one specific section – publications. The layout is very specific, but luckily I already have a form that generates exactly the output I want. It’s called publications_list, and is the form that is used to generate the contents page for that section.
The problem with this though is that it appears that I cannot include the publications_list form inside the sidebar form. And even if I could, it uses the txp:permlink, txp:article_image, and txp:title tags, for which there is no article context within the sidebar.
OK, take a step back. This is clearly not the right approach, and probably constitutes an abuse of the design principles behind Textpattern.
How should I tackle this, still trying to avoid duplicating code between templates?
(One obvious answer is to copy the sidebar source into each and every page template, so that I can include a txp:article_custom tag with limit=“1” section=“publications” form=“publications_list”. But the thought of duplicating this in the page template for every section fills me with horror… There must be a better way.)
Offline
Re: Best way to put article excerpt in sidebar?
txp:if_section and txp:article_custom
<txp:if_section name="publications">
<txp:article_custom limit="1" section="publications" form="publications_list" />
</txp:if_section>
<txp:if_section name="section4">
<txp:article_custom limit="1" section="section4" form="publications_list" />
</txp:if_section>
<txp:if_section name="section3">
<txp:article_custom limit="1" section="section3" form="publications_list" />
</txp:if_section>
Cheers!
Last edited by Gocom (2007-10-08 19:46:03)
Offline
#3 2007-10-08 19:51:54
- Ian Goldby
- Archived Plugin Author
- Registered: 2007-09-16
- Posts: 6
Re: Best way to put article excerpt in sidebar?
My goodness, that was easy. I don’t even need the txp:if_section tags, since the sidebar content is the same in every section.
I hadn’t realised that I can use txp:article and txp:article_custom in forms. I thought that they were ‘page tags’, meaning they could be used only in page templates.
Thank you for such a speedy and helpful answer!
Offline