Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: add id attribute to all article tags
Hi ruud,
thanks for your reply.
I’ve tested it but it seems that didn’t work.
On debugging mode I get:
tag_error <txp:article_custom id="4,2,6" form="estatico" /> -> Textpattern Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN (4,2,6) order by Posted desc limit 0, 10' at line 1
select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Status >= 4 and Posted <= now() and ID = IN (4,2,6) order by Posted desc limit 0, 10
Offline
Re: add id attribute to all article tags
The change also broke article_custom when it just has one value on id attribute.
Offline
Re: add id attribute to all article tags
Ah, the =
between ID
and IN
should be removed.
I’ve fixed the code in my previous example. Does that work as intended?
Offline
Re: add id attribute to all article tags
Committed in SVN as changeset 2888
Offline
Re: add id attribute to all article tags
Great, thanks!
I’ve tested it and it works fine!
I’ve read in the changeset that it doesn’t imply an order. Any chance to have the option of sorting them by the order in which the articles ids are on the id attribute?
Maybe something like sort=“id_attr”. :)
Offline
Re: add id attribute to all article tags
Something like this perhaps:
<txp:article_custom id="5,1,4,2,3" sort="FIELD(ID,5,1,4,2,3)" />
Offline
Re: add id attribute to all article tags
ruud wrote:
<txp:article_custom id="5,1,4,2,3" sort="FIELD(ID,5,1,4,2,3)" />
Sorry for the delay, is sort="FIELD(ID,5,1,4,2,3)"
something that currently works on TXP 4.0.6?
Or was it just an idea?
Offline
Re: add id attribute to all article tags
I never tested it, but assuming nothing gets escaped in that sort string, it should work.
Offline
Re: add id attribute to all article tags
It worked great! Thanks, Ruud!
Offline
#22 2008-06-10 16:27:56
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: add id attribute to all article tags
I assume this FIELD(ID,5,1,4,2,3)
is SQL, right? Does every txp tag with a sort attribute get along with some SQL? And what about plugins?
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: add id attribute to all article tags
It’s SQL yes. Basically whatever you set in the $sort attribute is used as: ORDER BY doSlash($sort)
, so as long as doSlash($sort) returns something valid that can be used after ORDER BY
in an SQL query, it’s okay. One thing that does NOT work is using quotes.
Offline