Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Expand article only if it's less than X days old?
For the context see the blog in question, http://sealpoet.com .
The author, who writes topical political commentary, wants the current blog entry expanded on the front page, and the previous few entries linked by title. Easy enough. However, he doesn’t always post new entries frequently enough to keep the site feeling “fresh” — so ideally the latest entry would be shown in fully expanded form for only, say, 7 days, then would collapse to a linked title like the previous entries.
The desired logic is:
if ( article date is < 7 days ago ) then { show as full article } else { show as bullet-item linked to full article }
I updated to v.4.0.8 in order to see if txp:if_expired could be used for this purpose; but in my experiments it hasn’t proved to be a suitable solution.
How would you implement this logic? Thanks for any tips.
Offline
Re: Expand article only if it's less than X days old?
I would have said that txp:if_expired
was the key, but you said on your experiments it didn’t seem to work.
What have you tried?
Off the top of my head, I would say that setting the expiring date 7 days in the future and then playing with if_expired
on your article form should do the job.
Offline
Re: Expand article only if it's less than X days old?
cbs_if_newer ought to do the trick.
For a no-plugin solution txp:variable
and txp:if_variable
ought to do it. I haven’t really used them myself, but I should think you could use them to compare the article’s txp:posted
value against date()
.
Code is topiary
Offline
Re: Expand article only if it's less than X days old?
Thanks jsoo, cbs_if_newer is exactly what was needed. It’s working well now.
maniqui — txp:if_expired provided the date logic I needed, but at the cost of… well… expiring the articles that were still of interest. If they were expired they simply didn’t display.
Offline
Re: Expand article only if it's less than X days old?
Admin: Preferences: Advanced: Publish: Publish expired articles? — (•) Yes.
And then <txp:if_expired />
(in an article listform) comes in case.
Last edited by Vienuolis (2009-07-23 00:00:12)
Offline
Re: Expand article only if it's less than X days old?
Vienuolis — thanks, that would have worked if I had stayed with 4.0.8. But I have now reverted to 4.0.6. The update was a pain — tracking down obscure error messages regarding plugin cache, e.g. Might have stayed with .8 except that a few unrelated things broke as well (e.g. “Next” and “Prev” links simply went away) and I just ran out of patience for it. And reverting required the help of a MySQL guru. My fault here, I hadn’t backed up the database in the right way ahead of time. Water under the bridge.
Offline