Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-12-04 11:21:08

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

if article exist in a specific section and category

how i can show something in the page (template) if article exist in a specific section and category?
something like this i tried, but that tag doesn’t exist on txp ;)

<txp:if_article section="news" category="india">
<h1>Show this area</h1>
</txp:if_article>

Last edited by raminrahimi (2015-12-04 11:21:44)

Offline

#2 2015-12-04 11:32:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: if article exist in a specific section and category

Use if_article_section and if_article_category nested inside each other.

If category india only ever occurs in the section news, you only need to test for if_article_category.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2015-12-04 13:06:02

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: if article exist in a specific section and category

Hi raminrahimi,

Other solution :

<txp:variable name="articles-list"><txp:article_custom section="your-section" category="your-category" form="your-form"  … />

<txp:if_variable name="article-list" value="">
    <p> Sorry, no article for this section and this category </p>
<txp:else />
    <txp:variable name="article-list" />
</txp:if_variable>

This solution is valable if you are out of your section and your category context.

Offline

#4 2015-12-04 14:38:18

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

Re: if article exist in a specific section and category

Hi Sacripant and *Jakob” !
Both solutions work fine for me, Thanks :-)

Offline

Board footer

Powered by FluxBB