Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2014-05-04 06:17:37
- zeraph
- New Member
- Registered: 2014-04-02
- Posts: 9
Output recent articles not sorted by date
This is probably quite a simple question, so please excuse my posting it, but I haven’t been able to find it through searching. Can article_custom output the most recent articles, but not sorted by date ?
I need to sort the recent articles by category only. Though I can technically do this, what is returned is not the most recent articles, but the first x number of articles out of a group that has been pre-sorted by category. I would like to first grab the most recent, say, 12 articles, then sort them by category.
Much thanks. :D
Last edited by zeraph (2014-05-04 06:27:08)
Offline
Re: Output recent articles not sorted by date
You can do it in two steps:
<txp:article_custom sort="Category1" limit="12"
id='<txp:article_custom limit="12" break=","><txp:article_id /></txp:article_custom>'
/>
Offline
Re: Output recent articles not sorted by date
Simpler :
<txp:article_custom sort=“Posted DESC, Category1 ASC” limit=“12” />
I’m pretty sure it works with <txp:article />
too.
Kill me.
Last edited by CeBe (2014-05-05 08:49:12)
Offline
Re: Output recent articles not sorted by date
I can not agree, Claire, désolé. Unless multiple articles are posted simultaneously, the Category1 ASC
clause will have no effect.
Offline
Re: Output recent articles not sorted by date
CeBe wrote #280584:
Simpler :
Sorting algorithms don’t work like that. An order by clause only affects the two rows being compared. The second permutation will only affect rows whose first is equal. The simplest way of doing this in plain SQL involves using subqueries, along the lines of:
select * from (select * from textpattern order by Posted desc limit 12) order by Category1
etc wrote #280586:
I can not agree, Claire, désolé. Unless multiple articles are posted simultaneously, the
Category1 ASC
clause will have no effect.
Yup, absolutely correct.
Last edited by Gocom (2014-05-04 22:09:53)
Offline
#6 2014-05-06 20:25:26
- zeraph
- New Member
- Registered: 2014-04-02
- Posts: 9
Re: Output recent articles not sorted by date
Much thanks everyone! I used etc’s solution to good effect.
Offline