Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-03-01 17:10:17

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

how to list articles ending in one week

hello forum,

i need to list all articles that have an expiry date set to one week in future from now. i don’t want to use custom fields but the regular article expires field.

after playing around for days i didn’t come close to a solution at all. so, i would greatly appreciate any ideas.

thanks, christoph

Offline

#2 2012-03-01 17:29:00

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: how to list articles ending in one week

1st rough thought is to tinker with: Store txp:expires in txp:variable. Check condition with plug-in smd_if or PHP.

I don’t see a solution with TXP core tags.

txp:article_custom needs an additional attribute :)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#3 2012-03-01 21:59:59

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: how to list articles ending in one week

Christoph, I’ve remodeled a plugin by Christian Sandberg (csb_if_newer_than) to work as you probably wish. Please try it (Edit: removed obsolete link) and report whether it does what you need.
(Edit: In the meantime an improved version of uli_if_expires_in has been officially released)

Last edited by uli (2012-03-03 21:53:58)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2012-03-01 23:17:25

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: how to list articles ending in one week

hi uli,

first things first: many thanks for coming up with this plugin! this is a community support that is overwhelming. simply fantastic.

i’ve tried it and it does what it is supposed to do. unfortunately it doesn’t match my needs 100%. since the tag has to be used inside article forms, it filters an array of articles. thus, if i have for example 3 articles with condition false and one with true, i get this output:

  • This article will not expire so soon
  • This article will not expire so soon
  • This article will not expire so soon
  • article xyz with condition = true

different to that, what i’m aiming for, is to output only articles with condition is true (e.g. restricting the article array to those with a given expiry date in future).

however, if this is cannot be easily achieved, at least your plugin will help me, to flag articles with condition true and to give them a different visual appearance. that should fill the bill if there are no alternatives.

thanks again, christoph

Last edited by totoff (2012-03-01 23:19:45)

Offline

#5 2012-03-01 23:28:25

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: how to list articles ending in one week

You’re welcome, Christoph. My fun.

totoff wrote:

different to that, what i’m aiming for, is to output only articles with condition is true (e.g. restricting the article array to those with a given expiry date in future).

If I understood you, you just need to leave the if edit: else part of the tag combo empty (nothing between the else tag and the closing tag).

Last edited by uli (2012-03-02 14:04:03)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2012-03-01 23:54:17

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: how to list articles ending in one week

Cool uli. I use that plugin too on sites and thought it would fit but after looking it up realised it didn’t work with expires. You went one better and made it do that!


TXP Builders – finely-crafted code, design and txp

Offline

#7 2012-03-02 08:37:55

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: how to list articles ending in one week

Good support Uli. Hat tip.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#8 2012-03-02 08:41:38

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: how to list articles ending in one week

hi uli,

puh, i was tired yesterday. sure leaving else out is the solution. many thanks again, hurray it works!

christoph

Offline

#9 2012-03-05 21:44:17

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: how to list articles ending in one week

hi uli,

thanks again for your great support. unfortunately we had a misunderstanding, which i just realized when i returned to work at this project: your plugin lists every article with an expiry date within one (or more) week from now. instead, what i was looking for was a way to list all articles matching the expiry date one week from now (e.g. per today march 5: list all articles ending march 12, but not march 11 or 10 and so on …).

so i have to come back to the forum asking if someone sees a chance to realize that?

best, christoph

Offline

#10 2012-03-05 21:54:55

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: how to list articles ending in one week

Christoph, I’m not sure I can follow, except for you want to list only articles that end exactly on 11th, neither one day later nor one day earlier. In that case simply nest two tags with dates that intersect for one day, i.e. leaving just a one day time frame.

Edit: the outer tag needs a value of 7 days, the nested (the second) conditional tag inserted in its if part. Into the second tag’s else part with a value of 6 days goes the tags you want to build your output with. At least if I’m not too tired. Else experiment along these lines ;)

[Edit 2: Yup.
I’ve set up an example, see plugin’s thread, first post, second code block.

Last edited by uli (2012-03-05 23:42:06)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2012-03-05 22:03:57

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: how to list articles ending in one week

hi uli,

yes, that’s it: i would like to list all articles that end precisely in one week from now. if today is march 5, list articles ending march 12. if today is march 6 list articles ending march 13 and so on. the idea behind is to have a daily changing list of events ending in one week from today, so people can decide to prefer this events over others because they end soon.

Offline

#12 2012-03-06 08:46:34

totoff
Member
From: Cologne, Germany
Registered: 2011-04-04
Posts: 145
Website

Re: how to list articles ending in one week

hi uli,

shame on me … i must have had a complete breakdown of logical thinking yesterday. of course, it makes no sense to output only events that end precisely on a given date. it must be all events in the timeframe before this date, as the plugin is intended to work …
apologize for demanding your time for nothing.

best, christoph

Offline

Board footer

Powered by FluxBB