Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-30 17:40:41

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

A first TXP Plugin: nab_if_future

Hi all,

Partly to learn about writing TXP plugins and how plugins work, I wrote a very simple one that I had a use for. It allows you to display content based on whether the article is set to post in the future.

For example, in an article form called by <txp:article time="any" />, you could have:

<txp:nab_if_future>
  <txp:excerpt />
<txp:else />
  <txp:body />
</txp:nab_if_future>

Download nab_if_future

Offline

#2 2009-08-30 21:17:41

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: A first TXP Plugin: nab_if_future

Neat!, next update you might pop in a call to assert_article(); right after the global declaration, against that occasion when an attempt is made to use the tag outside an article or single article mode context.

Offline

#3 2009-08-30 21:26:21

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

Re: A first TXP Plugin: nab_if_future

Thanks Rick! Will do. If I add assert_article(), do I still need to declare the global $thisarticle? – I see that line within the assert_article() function.

Offline

#4 2009-11-05 15:29:23

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: A first TXP Plugin: nab_if_future

Hi Nora

I’m getting a 404 for that link – is this one still available?

Stu

Offline

#5 2009-11-05 16:42:02

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

Re: A first TXP Plugin: nab_if_future

Should be up now! I changed hosts from aplus.net to hostgator in a fit of frustration, and I guess I forgot to upload the plugins folder. Sorry about that!

Offline

#6 2009-11-05 16:48:55

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: A first TXP Plugin: nab_if_future

Indeed it is. Thanks, and nice work :-)

Offline

Board footer

Powered by FluxBB