Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
How to achieve an <txp:if_future>?
If an article’s Posted date is in the future, I’d like Textpattern to display only the excerpt where it normally displays the body. Basically, I need a future equivalent to <txp:if_expired>. I think I could accomplish it with smd_if but that seems like overkill. <txp:variable />
also seems useful, but I’m not sure how to make greater than/less than comparisons with it.
Any ideas welcome!
Offline
Re: How to achieve an <txp:if_future>?
Okay, here’s what I came up with:
<txp:variable name="in_future" value='<txp:php>if($thisarticle["posted"] > time()) echo "true";</txp:php>' />
<txp:if_variable name="in_future" value="true">
<h2><txp:title /></h2>
<txp:excerpt />
<txp:else />
--all my normal article formatting--
</txp:if_variable>
Seems to work!
Offline
#3 2009-08-28 22:44:58
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to achieve an <txp:if_future>?
Nice :)
Offline
Re: How to achieve an <txp:if_future>?
I have made this snippet into the simplest plugin ever! I thought it would be a good opportunity for me to finally learn a little bit about how plugins work and how to write one, so here is nab_if_future.
Offline
#5 2009-08-30 17:27:14
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to achieve an <txp:if_future>?
Register your prefix :)
Offline
Re: How to achieve an <txp:if_future>?
Also, start a new thread in the Plugin Author Support forum:)
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: How to achieve an <txp:if_future>?
Thanks Els and Yiannis — I’ve done both of those things now.
Offline
Pages: 1