Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-13 23:44:31

coleh
Member
From: Edinburgh, UK
Registered: 2007-08-16
Posts: 28
Website

if_article_list

Hey

I am working on an article list defined by category.
All fine, linking to page okay and can get results for those articles which feature the relevant category name/title. However, I wanted to show a conditional argument if no articles were returned.

Was rather hoping a cunning combination of <txp:if_article_list /> and <txp:else /> would do the trick but it transpires that <txp:if_article_list /> returns a positive whether the article listing returns any articles or not. That it is being requested warrants its inclusion.

Anyone know how I might best achieve the above?
To clarify

  1. category listing
  2. when category defined article listing for articles featuring that category
  3. if no articles then message returned (no articles featuring that category, blah blah blah)

Cheers

Cole


Jack of all trades, Doctor of one

Offline

#2 2009-07-14 00:35:21

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: if_article_list

You can use the old but still useful chh_if_data plugin in your article form .
Or you can probably use the native txp:variable tag even if it is a little more convolute for me (see here)

Last edited by redbot (2009-07-14 19:06:35)

Offline

#3 2009-07-14 04:10:31

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: if_article_list

See:

For example, let’s first build the listing and put it into <txp:variable />:

<txp:variable name="articles" value='<txp:article />' />

The article tag there checks for articles and puts them into articles named variable. After that we can check if there is anything to show by using if_variable tags.

<txp:if_variable name="articles" value="">
	<!--
		We don't have any articles to show
	-->
	Sorry nothing here Mr. Anderson.
<txp:else />
	<!--
		Holy Cow, we have articles.
		Let's output the variable's content:
	-->
	<txp:variable name="articles" />
</txp:if_variable>

Last edited by Gocom (2009-07-14 04:12:04)

Offline

Board footer

Powered by FluxBB