Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-18 15:45:35

adastra
Member
From: St. Paul, MN
Registered: 2006-02-24
Posts: 20
Website

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

#2 2009-07-18 15:57:14

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-07-18 15:58:16

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#4 2009-07-22 14:50:41

adastra
Member
From: St. Paul, MN
Registered: 2006-02-24
Posts: 20
Website

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

#5 2009-07-22 23:55:53

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

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

#6 2009-07-23 00:22:10

adastra
Member
From: St. Paul, MN
Registered: 2006-02-24
Posts: 20
Website

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

Board footer

Powered by FluxBB