Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2008-05-17 21:48:22

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2008-05-17 21:50:21

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: add id attribute to all article tags

The change also broke article_custom when it just has one value on id attribute.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#15 2008-05-18 16:01:46

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#16 2008-05-18 21:02:07

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: add id attribute to all article tags

Committed in SVN as changeset 2888

Offline

#17 2008-05-18 22:59:03

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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”. :)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#18 2008-05-19 06:35:58

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#19 2008-06-09 18:15:30

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#20 2008-06-09 21:52:02

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#21 2008-06-10 13:55:43

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: add id attribute to all article tags

It worked great! Thanks, Ruud!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#22 2008-06-10 16:27:56

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

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

#23 2008-06-10 17:46:05

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

Board footer

Powered by FluxBB