Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-28 21:40:25

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

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

#2 2009-08-28 22:15:08

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

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

#4 2009-08-30 15:16:47

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

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

#6 2009-08-30 17:31:00

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

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

#7 2009-08-30 21:27:49

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: How to achieve an <txp:if_future>?

Thanks Els and Yiannis — I’ve done both of those things now.

Offline

Board footer

Powered by FluxBB