Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-12-30 01:06:49
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Articles that are current - i.e. their date span incorporates 'now'
I have an article with a posted
date in the past and an expires
date in the future – i.e. it is ‘current’.
How do I use article_custom
to list ‘current’ and ‘future’ articles? The attribute time="future"
doesn’t list ‘current’ articles.
My workaround is to output all articles, and use an if_expired
conditional to filter out ‘past’ events. Must be a better way of doing it!!
Offline
#2 2010-12-30 01:32:04
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Articles that are current - i.e. their date span incorporates 'now'
Set Publish expired articles to ‘no’?
Offline
Re: Articles that are current - i.e. their date span incorporates 'now'
<txp:article_custom time="any" />
lists both current and future articles. If your site preference is “Publish expired articles?” = NO, this should work for you.
Code is topiary
Offline
#4 2010-12-30 02:16:27
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Articles that are current - i.e. their date span incorporates 'now'
Thanks Els – that certainly makes sense
But I’ve now lost my archive lists – is there an override for article_custom
that allows expired articles to be published?
maybe that preference setting is too high-powered to be the solution here:
When set to “No”, expired articles will be removed from the public site and return a “410 Gone” HTTP status instead. Visiors hitting an expired article will be shown a custom page template named “error_410” if it’s present .
Offline
#5 2010-12-30 02:17:32
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Articles that are current - i.e. their date span incorporates 'now'
Just as background: I’m using posted/expired date fields for event start/finish dates
Offline
Re: Articles that are current - i.e. their date span incorporates 'now'
nardo wrote:
is there an override for
article_custom
that allows expired articles to be published?
Code is topiary
Offline
#7 2010-12-30 20:47:40
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Articles that are current - i.e. their date span incorporates 'now'
Thanks jsoo
with arc_pref_override
I can now display an archive list of expired articles … but getting 401 gone
when clicking through to the individual article page …
have def. wrapped the article tag with the plugin code … can anyone confirm that this plugin works with individual article pages?
Offline
Re: Articles that are current - i.e. their date span incorporates 'now'
For individual article pages, the “publish if expired” check happens early, in preText(). So maybe it would work the other way around: set Publish Expired Articles? to YES, then use arc_pref_override for the event list.
Code is topiary
Offline
#9 2010-12-30 21:30:59
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Articles that are current - i.e. their date span incorporates 'now'
Thanks again – I’ve switched the logic as you suggest, all good
Follow up question – I need to construct an SQL query to directly access this site’s database from an external site … to get back current & future articles … I could access a custom RSS feed (I have one already) but way it’s set up, prefer the SQL connection … can you suggest how to approach this? … so far I’ve been setting the site to ‘debugging’ and grabbing the required SQL queries from the resulting dump!!
Offline
Re: Articles that are current - i.e. their date span incorporates 'now'
Is the other site also a Txp site? Is it on the same server? Have you succeeded in getting a DB connection with the queries you’ve tried?
Code is topiary
Offline
#11 2010-12-31 00:43:21
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Articles that are current - i.e. their date span incorporates 'now'
I have a DB connection & I’m successfully pulling articles from the Txp site to a second site (different server, ASP-based). It works nicely.
The issue is that I want only to get ‘current’ and ‘future’ articles in this context too! But not sure how to build an appropriate SQL query for this particular circumstance.
Offline
Re: Articles that are current - i.e. their date span incorporates 'now'
SELECT * FROM textpattern WHERE (NOW() <= Expires OR Expires = '0000-00-00 00:00:00')
i.e., articles without an expiration date, or with an expiration date in the future.
Code is topiary
Offline