Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-31 00:16:06

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

[resolved] [Solved] Don't name a custom field "sort"

I wanted to sort articles on a custom field, and had the bright idea of naming that field “Sort”. Suddenly article lists came up blank. Eventually figured out that if any custom field is named “sort” or “Sort”, it messes up any <txp:article /> or <txp:article_custom /> tag that has the sort attribute set. (But not a problem when using the deprecated sortby attribute instead.) The SQL gets

and custom_n like 'foo'

added to the end of the where clause, where custom_n is the custom field named “sort” and foo is the value of the sort attribute in the article tag.

So don’t name any custom field “sort”.

Just thought I’d share.


Code is topiary

Offline

#2 2008-12-31 00:33:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: [resolved] [Solved] Don't name a custom field "sort"

D’oh. For some reason it was missing from the list of reserved words on Textbook but I’ve now updated it to include ‘sort’.

Thanks for the tip :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2008-12-31 01:05:44

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [resolved] [Solved] Don't name a custom field "sort"

Thanks! Until I got into this mess I didn’t even know there was a list of reserved names re custom fields.


Code is topiary

Offline

#4 2008-12-31 01:13:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: [resolved] [Solved] Don't name a custom field "sort"

jsoo wrote:

Until I got into this mess I didn’t even know there was a list of reserved names re custom fields.

Hehe. Keeps you on your toes ;-)

Actually, thinking about it some more, my original assumption when updating that Textbook entry was that you should avoid things like column names in the textpattern table and/or variables that are populated in $thisarticle or $pretext. But in light of your finding I’d wager that some (all?) MySQL reserved words might cause problems as well. For example order, select, update, insert… hmmmm.

That might not be the case but it follows from your observation. I’ll wait for clarification on this one from some TXP gurus before making any further changes to Textbook.

Last edited by Bloke (2008-12-31 01:14:09)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2009-03-14 05:57:59

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: [resolved] [Solved] Don't name a custom field "sort"

thanks for this – long-time problem solved!

Offline

Board footer

Powered by FluxBB