Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2010-05-17 17:32:32
- river
- New Member
- Registered: 2010-05-17
- Posts: 2
If No Future Articles, Do This
Hello!
I’m attempting to do something I thought would be quite popular and easy to find a how-to for on the forums, but all my searching has turned up nothing.
I want to list future articles from a specific section and if there are no more future articles, to display some text.
What I thought might work is this:
<txp:if_article_list>
<txp:article_custom sort="Posted asc" time="future" section="events" form="events" limit="5" />
<txp:else />
There are no upcoming events.
</txp:if_article_list>
However, that does not work. I’ve also looked through every post on the smd_if thread but didn’t see anyone that was attempting to do what I’m doing. Is there a simple way to go about this that I’m missing out on?
Thanks!
Offline
Re: If No Future Articles, Do This
The code above is not semantically correct, as it just means:
<txp:if_article_list>
<!-- if we are in an article list, like a section or category frontpage -->
<txp:article_custom sort="Posted asc" time="future" section="events" form="events" limit="5" />
<txp:else />
<!-- we are not in article list, we are in individual article context, that is, in article's permanent link -->
There are no upcoming events.
</txp:if_article_list>
You could try this:
<txp:variable name="has_future_articles" value='<txp:article_custom sort="Posted asc" time="future" section="events" form="events" limit="5" />' />
<txp:if_variable name="has_future_articles" value="">
There are no upcoming events.
<txp:else />
<txp:article_custom sort="Posted asc" time="future" section="events" form="events" limit="5" />
</txp:if_variable>
Notice the single quotes when using txp tags inside txp tags (on txp:variable
value
attribute).
Offline
#3 2010-05-17 17:43:41
- river
- New Member
- Registered: 2010-05-17
- Posts: 2
Re: If No Future Articles, Do This
Oh man, that totally worked!
Thanks so much!
Offline
Pages: 1