Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-31 13:02:58

LetterHoofd
Member
From: Kortrijk, BE
Registered: 2006-01-20
Posts: 40
Website

Single/multiple articles in category

How do I handle this?

If some category only has 1 article, how do I force it to show only the one article in full, instead of a list of one article?
And if the category has multiple articles, it should show the list of articles.

Offline

#2 2009-08-31 13:43:21

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

Re: Single/multiple articles in category

Should get you started:

<txp:if_individual_article>
	<txp:article limit="1">
<txp:body />
</txp:article>
</txp:if_individual_article>
<txp:if_article_list>
	<txp:article>
<txp:excerpt />
</txp:article>
</txp:if_article_list>

Last edited by jstubbs (2009-08-31 13:48:15)

Offline

#3 2009-08-31 13:49:37

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Single/multiple articles in category

Methinks OP is asking for something quite different: when an article list consists of only one article, not at all the same as individual article context.

I think you’ll need a plugin to count the articles, such as mdn_count or mem_article_count, then use variable and if_variable for the logic.


Code is topiary

Offline

#4 2009-08-31 14:15:54

LetterHoofd
Member
From: Kortrijk, BE
Registered: 2006-01-20
Posts: 40
Website

Re: Single/multiple articles in category

@jsoo, you got me in the right direction.

<txp:variable name="single" value='<txp:mdn_count category="#"/>' />
<txp:if_variable name="single" value="1">
One article
<txp:else />
Article list
</txp:if_variable>

Last edited by LetterHoofd (2009-08-31 14:16:50)

Offline

#5 2009-08-31 14:29:25

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Single/multiple articles in category

I think one could adapt the TXP code in Els’ TXP Tip that deals with a similar issue where a single article in a section (as opposed to the category in LetterHoofd’s requirement) receives a different treatment to a more than one articles in a section.

Offline

#6 2009-08-31 15:11:22

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Single/multiple articles in category

Good one, Joe. Once again Els has the no-plugin answer.


Code is topiary

Offline

Board footer

Powered by FluxBB