Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-13 15:57:31

leafy_loader
Member
Registered: 2008-09-25
Posts: 96

Find wether only one article listed

I’m trying to determine wether a category only has 1 article assigned before it outputs the data. I want it to output a list of article titles except when there is only one article.

I’m trying to achieve this using <txp:if_individual_article> but that doesn’t seem to work in this context. Here’s my code:

<txp:article form=“title_list” /> – this calls the following code;

<txp:if_individual_article> do something different
<txp:else />
<li<txp:if_first_article> class=“current”</txp:if_first_article>><a href=”?s=<txp:section />&c=<txp:category />#point_<txp:article_id />” title=”<txp:title />”><txp:title /></a></li>
</txp:if_individual_article>

It produces a list of titles as links, which is fine but can’t get it to behave differently if there is only one article.

Offline

#2 2009-12-13 16:43:41

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

Re: Find wether only one article listed

if_individual_article looks at the context, not the number of articles called, so won’t work for this.

Just a rough idea, a combination of if_first_article, setting a variable to the value of link_to_next, and if_variable could do it.


Code is topiary

Offline

#3 2009-12-13 17:12:57

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Find wether only one article listed

See this tip on TXP Tips, it does more or less what you need for a section_list. Just grab the part from the code example that checks for the number of articles.

Last edited by els (2009-12-13 17:15:09)

Offline

Board footer

Powered by FluxBB