Show teaser from a future article

On a site I was working on recently, I wanted to show a “teaser” about an upcoming article. I may have several articles set to publish on future dates, and I wanted show a snippet of the article that is set to publish next. I came up with the following code to accomplish this:

<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 />
  --normal article formatting--
</txp:if_variable>

Also in plugin form

This is easy enough, but I also went ahead and made it into a tiny plugin, called nab_if_future.

Usage would be as follows:

<txp:nab_if_future>
  <txp:excerpt />
<txp:else />
  --normal article formatting--
</txp:nab_if_future>
comments powered by Disqus