Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2015-05-30 10:15:29
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
sort order of articles
hi,
i need to sort articles from section products by ID-s.
is this correct, working code?
<txp:article_custom section="products" sort="field(section,81,73,77,84,45,64,78)" />
Offline
Re: sort order of articles
I might be wrong but what I think that you need is
<txp:article_custom section="products" sort="ID (81,73,77,84,45,64,78)" />
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#3 2015-05-30 10:51:06
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: sort order of articles
i interpreted example 6
Offline
#4 2015-05-30 12:08:24
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: sort order of articles
colak wrote #291157:
I might be wrong but what I think that you need is
<txp:article_custom section="products" sort="ID (81,73,77,84,45,64,78)" />...
nope:
Tag error: <txp:article_custom limit="50" section="tooted" wraptag="ul" break="li" class="tooted" sort="ID (26,25,24,23,22,21,20,19,18,17,16)"> -> Textpattern Error: FUNCTION trykised.eu.ID does not exist while parsing form tooted_vasak_tulp on page default
my exact code:
<txp:article_custom limit="50" section="tooted" wraptag="ul" break="li" class="tooted" sort="ID (26,25,24,23,22,21,20,19,18,17,16)">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
Offline
Re: sort order of articles
I don’t think your (original) version can work, because you’re comparing sections with id numbers and it won’t find them (the field
derives (I think) from MySQL, so your version looks for entries in the field “section” which will be names not numbers). I think you need:
<txp:article_custom id="81,73,77,84,45,64,78" sort="field(id,81,73,77,84,45,64,78)" />
As you are already specifying id numbers, you don’t need to additionally provide the section as an attribute (unless some of those numbers aren’t in the products section, that is). If those are the only id numbers in that section, that will suffice.
If you have other article id numbers in the products section, you can try
<txp:article_custom section="products" sort="field(id,81,73,77,84,45,64,78)" />
and then see what happens with the article id numbers you don’t specify in the sort …
TXP Builders – finely-crafted code, design and txp
Offline
#6 2015-05-30 12:20:32
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: sort order of articles
jakob wrote #291163:
If you have other article id numbers in the products section, you can try
<txp:article_custom section="products" sort="field(id,81,73,77,84,45,64,78)" />...
and then see what happens with the article id numbers you don’t specify in the sort …
yes i do. this solution didn’t work either: it outputs all articles from section
Offline
#7 2015-05-30 12:50:15
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: sort order of articles
Strange, but I’m working actually on a site where I use the simple code below, and it works, the article order is the same as the order of the IDs. And if I change the order of the IDs, the article order changes according to the ID order:
<txp:article_custom id='<txp:custom_field name="cf-name" />' form="form" />
Offline
#8 2015-05-30 13:36:10
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: sort order of articles
GugUser wrote #291165:
Strange, but I’m working actually on a site where I use the simple code below, and it works, the article order is the same as the order of the IDs. And if I change the order of the IDs, the article order changes according to the ID order:
<txp:article_custom id='<txp:custom_field name="cf-name" />' form="form" />...
this is not the same. i want to take article ids from content>articles
Offline
#9 2015-05-30 13:43:08
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: sort order of articles
What’s the difference? What are “IDs from content>articles”?
Offline
#10 2015-05-30 15:32:14
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: sort order of articles
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?
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: sort order of articles
Sorry, I should have written under the first option I suggested:
If those are the only id numbers in that section that you want to show, then that will suffice.
TXP Builders – finely-crafted code, design and txp
Offline
#12 2015-05-30 15:47:06
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: sort order of articles
See also Oleg/etc’s post for a shorthand version.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline