Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2017-07-11 06:07:46
- raminrahimi
- Member
- From: India
- Registered: 2013-03-19
- Posts: 278
if a category has article
I’m posting vacancies (articles) on my vacancy category and chosing expiry date as well to hide when expired.
now i want to list articles which is not expired, if there is no article to show then i want to appear a text “currently no vacancy avalible”
<txp:article_custom category="vacancy" limit="5">
<li><txp:title /></li>
</txp:article_custom>
Offline
Re: if a category has article
HI raminrahimi
would this work?
<txp:variable name="hasvacancy"><txp:article_custom category="vacancy" limit="1" break="" wraptag=""><txp:article_id /></txp:article_custom></txp:variable>
<txp:if_variable name="hasvacancy" value="">
<txp:article_custom category="vacancy" limit="5" wraptag="ul">
<li><txp:title /></li>
</txp:article_custom>
<txp:else />
<p>There is no vacancy available</p>
</txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: if a category has article
or use plugin aks_article
<txp:aks_article category="vacancy" limit="5" wraptag="ul" break="li"> <txp:title /> <txp:else /> <p>There is no vacancy available</p> </txp:aks_article>
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
Re: if a category has article
I guess Yiannis means
<txp:variable name="hasvacancy"><txp:article_custom category="vacancy" limit="5" wraptag="ul" break="li">
<txp:title />
</txp:article_custom></txp:variable>
<txp:if_variable name="hasvacancy" value="">
<p>There is no vacancy available</p>
<txp:else />
<txp:variable name="hasvacancy" />
</txp:if_variable>
In 4.7, <txp:evaluate />
will make it easier:
<txp:evaluate>
<txp:article_custom category="vacancy" limit="5" wraptag="ul" break="li">
<txp:title />
</txp:article_custom>
<txp:else />
<p>There is no vacancy available</p>
</txp:evaluate>
Independently, would <txp:else />
in <txp:article />
à la aks_article
be useful and not confusing?
Edit: by confusing I mean you will not be able to use form
attribute if <txp:else />
is present, you’ll have to write
<txp:article_custom>
<txp:output_form form="my_form" />
<txp:else />
nada
</txp:artilce_custom>
Offline
Re: if a category has article
etc wrote #306237:
I guess Yiannis means
<txp:variable name="hasvacancy"><txp:article_custom category="vacancy" limit="5" wraptag="ul" break="li">...
Hi Oleg, I guess both would work but yours is more efficient as it does not have to call for the articles twice.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: if a category has article
Hi Yiannis, actually the if/else
logic is switched in yours :-)
Offline
#7 2017-07-11 08:54:56
- raminrahimi
- Member
- From: India
- Registered: 2013-03-19
- Posts: 278
Re: if a category has article
Thanks from all :-)
Offline
Re: if a category has article
etc wrote #306239:
Hi Yiannis, actually the
if/else
logic is switched in yours :-)
!!! Indeed!!! whoops ?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1