Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-02-17 19:14:25

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Display only expired articles

Hello Txp users,

I want display a list of expired articles.

expired attribut exist but I can’t diplay only expired articles

<txp:article expired="0" /> display only non expired articles (exclude expired articles)
<txp:article expired="1" /> display expired AND non expired articles

Someone has a solution for displaying only expired articles ?

Edit : In documentation, expired attribut exist only for article_custom tag. But in my test, it work for article too.

Last edited by sacripant (2014-02-17 19:16:01)

Offline

#2 2014-02-17 20:34:06

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: Display only expired articles

What about:

<txp:if_expired>
  <txp:article />
</txp:if_expired>

?

Edit (me too): expired works if <txp:article /> returns an article list. I think it doesn’t in an individual article context.

Last edited by CeBe (2014-02-17 20:49:16)

Offline

#3 2014-02-17 20:47:38

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Display only expired articles

CeBe wrote #279031:

What about:

Shouldn’t if_expired be inside the article tag or form? Like this:

<txp:article>
  <txp:if_expired>
    ...
  </txp:if_expired>
</txp:article>

But I think this will mess with the article count.

Offline

#4 2014-02-17 20:51:18

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Display only expired articles

sacripant wrote #279029:

Edit : In documentation, expired attribut exist only for article_custom tag. But in my test, it work for article too.

Isn’t it so that <txp:article /> accepts all attributes that exist for <txp:article_custom />, except the ones that are taken from globals (like section, category and so on)?

Offline

#5 2014-02-17 20:52:34

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Display only expired articles

sacripant wrote #279029:

Someone has a solution for displaying only expired articles ?

You will probably need smd_ or etc_query.

Offline

#6 2014-02-17 20:54:33

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: Display only expired articles

Els wrote #279033:

Shouldn’t if_expired be inside the article tag or form?

It should, yes.
Sorry.

Offline

#7 2014-02-17 21:52:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,776
Website GitHub

Re: Display only expired articles

No immediate solution springs to mind, sorry. I even tried using <txp:if_status status="410"> to see if the list would only display them (if Publish expired articles pref is off) but it didn’t work because the tag attribute overrides the throwing of the status code. Looks like you’ll have to construct the query yourself for now or go with one of the above and lose accurate article counts / pagination.

I wonder if there’s some value we could permit in the expired attribute that would make sense to only return expired articles? Any thoughts anyone? Or is that a crap idea?

Incidentally, yes, Els is right. The article tag accepts pretty much the same attributes as article_custom (they run the same, or very similar, code), it’s just that some of the attributes get ignored or overridden by the current context when using <txp:article />. So we don’t normally document these undocumented features, because a lot of the attributes just don’t make sense in a pure article context. But expired does make sense for both, so maybe it should be added to the txp:article documentation.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2014-02-18 11:21:14

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Display only expired articles

Thanks for your answers, even if they are not good news :(
I’ll make something with <txp:if_expired> or perhaps offset attribut (I count not expired article with a first query and I offset result…)

In my case, I use date fields to indicate the beginning (posted date) and end (expires date) of an event.
And I want to display a list of upcoming events (not yet expired) and a list of past events (expired).
On paper it seemed simple…

I wonder if there’s some value we could permit in the expired attribute that would make sense to only return expired articles? Any thoughts anyone? Or is that a crap idea?

In my memory, this attribute already allowed that. But I was wrong.
Why allow expired attribut to filter items not expired and not permit the reverse?

The problem is that the attribute “expired” is based on a boolean value. And Boleen value is not scalable, only two values are possible …
And if you could add a third value, it would
expired = "-1" would have more sense than expired = "2"

Last edited by sacripant (2014-02-18 11:22:19)

Offline

#9 2014-02-18 17:52:29

woof
Member
Registered: 2004-08-01
Posts: 128

Re: Display only expired articles

sacripant wrote #279029:

Someone has a solution for displaying only expired articles ?

you could try soo_article_filter (see 1st example)

Offline

#10 2014-02-18 19:37:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,171
Website GitHub Mastodon Twitter

Re: Display only expired articles

Did you try <txp:article_custom time="past" />?

>Edit: Reading your first post I guess you did

Last edited by colak (2014-02-18 19:50:01)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#11 2014-02-18 22:32:14

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Display only expired articles

I don’t understand exactly what the real problem is in this treat. Why doesn’t work for you something like the following? May be you don’t need txp:if_first_article and you put the h2 at the beginning and may be you need more attributes, but it’s only an example, and it works:

<txp:article_custom limit="999">
	<txp:if_first_article>
		<h2>Upcoming events</h2>
	</txp:if_first_article>
	<p><txp:title /></p>
</txp:article_custom>
<h2>Past events</h2>
<txp:article_custom limit="999" expired="1" sort="Expires desc">
	<txp:if_expired>
		<p><txp:title /></p>
	</txp:if_expired>
</txp:article_custom>

Offline

#12 2014-02-19 08:02:30

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: Display only expired articles

woof wrote #279065:

you could try soo_article_filter (see 1st example)

Thanks, Good Catch, Jeff Soo is back !.
At the moment I use the offset attribute, and it works well. But I keep this solution in some case.

@GugUser.

Yes, your code work, but as explained above, using <txp:if_expired> will mess with the article count. This solution is not compatible with a pagination system, or use break attribute, or simply share the same article form for easier maintainability

Offline

Board footer

Powered by FluxBB