Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-03-07 06:13:03

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

if no article found, message appear

here i listed all my future events:

<txp:article form="upcoming-events" time="future" section="upcoming-events" limit="5" />

now i need to appear a message of “No Article Found” if there is no listed articles found.
thanks

Offline

#2 2015-03-07 06:17:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,171
Website GitHub Mastodon Twitter

Re: if no article found, message appear

<txp:variable name="hasarticle" value='<txp:article form="upcoming-events" time="future" section="upcoming-events" limit="1" />'  />
<txp:if_variable name="hasartcle" value="">
No Article Found
<txp:else />
<txp:article form="upcoming-events" time="future" section="upcoming-events" limit="5" />

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2015-03-07 12:08:35

etc
Developer
Registered: 2010-11-11
Posts: 5,393
Website GitHub

Re: if no article found, message appear

You’d better reuse the variable, rather than calling <txp:article /> twice, especially with different limit attributes (can break pagination):

<txp:variable name="hasarticle" value='<txp:article form="upcoming-events" time="future" section="upcoming-events" limit="5" />'  />
<txp:if_variable name="hasartcle" value="">
	No Article Found
<txp:else />
	<txp:variable name="hasarticle" />
</txp:if_variable>

Offline

#4 2015-03-09 18:04:32

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: if no article found, message appear

Perfect :-)

Offline

Board footer

Powered by FluxBB