Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-16 10:21:59

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

[howto] Recent articles, individual articles & article archive in one section

Say you’ve got a section on your site called ‘journal’. On the section homepage (/journal), you want the 10 most recent articles displayed, each linking to their individual article page (e.g. /journal/first-post). But you also want a master archive page, that lists all articles (by year, month & title) within the journal section so that your navigation menu retains its active state as ‘journal’. Here’s a simple way (granted, uses a plugin) that puts together a couple of techniques already noted in these forums (thanks Rachel Rachel and Zem).

1. Download and install chs_if_urlvar

2. You have a section named ‘journal’.

3. The following goes in your default page template:
<code>
<txp:if_section name=“journal”>
<txp:chs_urlvar_default var=“view”>
<txp:article listform=“journal-list” form=“journal-single” />
<p><a href=”/journal/?view=archive”>Journal Archive</a></p>
</txp:chs_urlvar_default>
<txp:chs_if_urlvar var=“view” value=“archive”>
<txp:article listform=“journal-archive” limit=“999” />
<p><a href=”/journal”>Latest Journal Entries</a></p>
</txp:chs_if_urlvar>
<txp:else />
<txp:article />
</txp:if_section>
</code>

4. You make 3 new article forms:

## “journal-list” which has e.g. the article title wrapped in a permalink, the posted date & excerpt
## “journal-single” which has article title, body & comments
## “journal-archive” which uses the code from step #1 in Zem’s FAQ entry How do I make an archive page?

5. That’s it. All you’re doing is making this URL “/journal/?view=archive” and specifying how you’d like your articles listed when it’s called.

Offline

Board footer

Powered by FluxBB