Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-05-30 17:39:56

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

Re: sort order of articles

I’m testing in my installation and it works like this:

<txp:article_custom id="13,5,10" etc. />

The article order is the order of the IDs. If I change the ID order, the article order changes. Where is the problem? What I understand wrong?

Last edited by GugUser (2015-05-30 17:40:59)

Offline

#14 2015-05-30 18:34:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: sort order of articles

See also Oleg/etc’s post for a shorthand version

I saw that too and am in two minds about it. One the one hand using sort="" is much more user-friendly than using field… but on the other hand it looks like a mistake or that it’s simply been forgotten.

The article order is the order of the IDs.

That’s interesting GugUser.

The docs definitely say something different:

id="article ID"
Display the specific article or list of articles (each ID separated by a comma).
IMPORTANT: When a list is supplied, this does not imply a sort order (see Example 6).

and

sort="…"
Default: Posted desc.

But your results would seem to suggest that using a custom id order overrides that. if it consistently works as you suggest, then that is a whole lot easier (… and you are right again!!).


TXP Builders – finely-crafted code, design and txp

Offline

#15 2015-05-30 19:59:21

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

Re: sort order of articles

jakob: In the case of my current project that definitely works. The desired order of the IDs outputs the same article order. This is not a theoretical statement, simply I can reproduce it.

Offline

#16 2015-05-30 20:30:08

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

Re: sort order of articles

GugUser, you’re totally right! :) Seems we’ve all missed this:

Changes in 4.5.0
[…]
<txp:article_custom>, <txp:file_download_list> preserve sorting order from ‘id’ attribute
[…]
<txp:images /> preserves sorting order from article image ids

(Quoted from HISTORY.txt)

PHEW!! :]


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

Offline

#17 2015-05-30 20:44:53

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

Re: sort order of articles

I remembered this related to the images IDs, but with respect to article_custom I had forgotten it completely. I experimented empirically and was surprised about the result. Good that you have found the documentation about this. So we can remember this useful detail.

Last edited by GugUser (2015-05-30 20:45:17)

Offline

#18 2015-05-31 07:08:28

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: sort order of articles

uli wrote #291168:

Any specific reason, gallex, why you didn’t use the example from the docs like it is, without interpreting it, or the first one jakob proposed, respectively?

hoped to find “less numbers” solution – easier for client.

Offline

#19 2015-05-31 07:40:19

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: sort order of articles

Well observed GugUser and well spotted Uli. Someone with the corresponding rights should amend the docs accordingly. That makes things a whole lot more obvious.

hoped to find “less numbers” solution – easier for client.

Agreed. If you want to make it totally user-controllable, you could use stm_article_order to allow the user to change the sort order manually and if you just want a selection of products to show, you could assign them to a category and then only output articles from that category instead of by ID. If you are already using both the categories, you could alternatively use a custom field (e.g. a checkbox with “Featured article? yes/no”) as a means of outputting only certain products, or use smd_featured. Perhaps one of those helps.


TXP Builders – finely-crafted code, design and txp

Offline

#20 2015-05-31 07:41:42

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: sort order of articles

GugUser wrote #291173:

I’m testing in my installation and it works like this:

<txp:article_custom id="13,5,10" etc. />...

The article order is the order of the IDs. If I change the ID order, the article order changes. Where is the problem? What I understand wrong?

you are totally right – working me too. thank’s guys!

final code:

<txp:article_custom id="26,25,24,23,22,21,20,19,18,17,16" limit="50" section="tooted" wraptag="ul" break="li" class="tooted">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>

Offline

#21 2015-05-31 13:46:09

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

Re: sort order of articles

Gallex wrote #291183:

hoped to find “less numbers” solution – easier for client.

Ah, OK, didn’t think of clients, I never grant them accessing forms or pages, I let them edit an mck_snippet on the Content panel or, like jakob mentioned, install stm_ao if it’s just about letting them arrange the articles order.


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

Offline

#22 2015-05-31 14:01:01

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: sort order of articles

jakob wrote #291176:

One the one hand using sort="" is much more user-friendly than using field… but on the other hand it looks like a mistake or that it’s simply been forgotten.

Sorry for having overlooked this: sort="" is default now, so one can get rid of it (amended my previous post).

To complete the discussion, if you call

<txp:article_custom section="products" sort="FIELD(ID,81,73,77,84,45,64,78)" />

then you get first other articles (in some random order), then the articles 81,73,... in the required order. If you want to output the featured articles first, followed by other articles, you should inverse the order:

<txp:article_custom section="products" sort="FIELD(ID,78,64,45,84,77,73,81) DESC" />

Offline

Board footer

Powered by FluxBB