Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-24 21:45:11

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Using posted and exipred dates as beginning and ending dates?

I’m using the “Posted” date as the beginning date of exhibits and the “expired” date as the ending date. Now I’d like to have separate pages for “current” (date falls between posted and expired) past (both dates are in the past) and upcoming (both dates in the future). Is there a way to do this just with txp:article_custom, or do I need separate article forms for each case, and some clever txp:if_expired wrangling?


Yes, I have tried turning it off and on.

Offline

#2 2009-02-25 11:46:21

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Using posted and exipred dates as beginning and ending dates?

Hi alesh.

<txp:article/> & <txp:article_custom/> are a bit lacking in functionality when it comes to specifying Posted/Modified/Expired dates.

There was a plugin, chh_article_custom, which had some useful attributes but it spews out loads of errors now & is unsupported as well.

I’ve used ras_if_dates in article forms with great success. Also, now there’s the standard TXP 4.0.7+ tags <txp:if_expired/>.

I had to revisit a scenario recently where I wanted to list “today’s” articles and found that using month="yyyy-mm-dd" does the job, together with a bit of PHP to generate today’s date, and a TXP variable to make things neat:

<txp:variable name="today" value='<txp:php>echo date("Y-m-d");</txp:php>'/>
<txp:article_custom section="diary" time="any" month='<txp:variable name="today" />' />

It only looks at the ‘Posted’ date but you might be able to combine it with <txp:if_expired/>.

Offline

#3 2009-02-26 21:42:05

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Re: Using posted and exipred dates as beginning and ending dates?

Ok, thanks, I’ll give it a shot and report back shortly. (Seems like adding the expiration date as an attribute for other tags would be a natural direction to develop in tho, no?)

Last edited by alesh (2009-02-26 21:42:22)


Yes, I have tried turning it off and on.

Offline

#4 2009-02-27 22:27:38

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Re: Using posted and exipred dates as beginning and ending dates?

Ahh… not very elegant, but this seems to work: My page has this tag:

<txp:article form="visual-current" />

And the form “visual-current” is this:

<txp:if_expired><txp:else />

<div class="item"><h4><txp:permlink><txp:article_image class="floatright" thumbnail="0" /><txp:title /></txp:permlink></h4>
<txp:if_excerpt>
<txp:excerpt /><p class="button" ><txp:permlink>more</txp:permlink><txp:rss_article_edit prefix=" ">::</txp:rss_article_edit></p>
<txp:else />
<txp:body /><p><small><txp:permlink>#</txp:permlink></small></p></txp:if_excerpt>
<txp:if_comments><p><txp:comments_invite /></p></txp:if_comments></div>

</txp:if_expired>

Yes, I have tried turning it off and on.

Offline

Board footer

Powered by FluxBB