You are not logged in.
i would like to customize my sortorder: ordering without, for example, starting The, De, Die, Der, etc.
Analog this tip (maybe old but still relevant..) I tried
<txp:article sort="replace(Title,'The ',''),Title" />
However, the ‘ is replaced (by Txp doSlash = mysql_real_escape_string, which is perfectly safe!).
But, how do I escape this, while writing my tag?
 textile formatting
Last edited by testdeputy (2011-09-06 13:50:03)
If you don’t mind using a plugin, soo_article_filter will do what you want.
Thanks for suggesting, but the plugin soo_article_filter will not suffice:
“main issue is that if the page context is search results (i.e., the q query parameter is set), the tag will simply parse its contents and return them as is”.
My goal is, amongst other, ordering a search. The plugin will do nothing when a search is performed.
 tried this a bit, also needs an xtra custom field … bummer
Remains the question: how to escape ‘?
I guess the answer is: can’t be done.
Last edited by testdeputy (2011-09-06 13:51:13)
Your SQL probably worked if you’d use
’ or a
‘ in your titles, which – on top – is typographically correct. Is that enticing enough?
My working sql looks like
ORDER BY REPLACE(Title,'The ','') DESC or similar.
A single quote is used here?
What exactly do you want sorted out, or am I missing something? I was referring to cases like
D'Artagnan, where no straight quotes should be used.
the tag I would like to write looks similar to
<txp:article limit="5" sort="REPLACE(REPLACE(REPLACE(Title,'The ',''),'A ',''),'An ','') ASC,Title" />
Don’t think there’s a way round it because
doSlash() is immutable.
The only way I can find is to use smd_query because it trusts you to escape your own data or provide paranoia-fuelled filtering rules. It only escapes GET/POST data by default, not your own
query attribute, since the plugin assumes you trust yourself :-)
The following approach works for me, but you’ll need to be creative with the WHERE clause and quotes if you want to pull stuff out from the current section only:
<txp:smd_query query="SELECT * FROM textpattern WHERE 1=1 ORDER BY TRIM(LEADING 'The ' FROM TRIM(LEADING 'A ' FROM TRIM(LEADING 'An ' FROM Title))) ASC,Title" populate="article" limit="10"> <txp:permlink><txp:title /></txp:permlink> <txp:excerpt /> </txp:smd_query>
You can also paginate the results if you wish.
Last edited by Bloke (2011-09-06 14:53:40)
For now, underlying case is a private website, I decided to hack
publish.php and disabled the
doSlash on the sort clause.
Maybe I trust myself, hahaha (already hacked that file anyway, to enable search in custom fields), or will learn the hard way.
The smd_query plugin looks very interesting for another project, bookmarked!
And thanx very mucho for your WAAAAAY better suggestion of handling starting The, A, etc. with
 taking it up a notch..
TRIM(LEADING LOWER('The ') FROM TRIM(LEADING LOWER('A ') FROM TRIM(LEADING LOWER('An ') FROM LOWER(Title)))) ASC,Title
saves a bit when handling ‘the’ against ‘The’, ‘a’ against ‘A’, etc.
It’s a long way to perfectness, but a fine road to ride.
Last edited by testdeputy (2011-09-06 23:48:51)
already hacked that file anyway, to enable search in custom fields
Textpattern has preference option for adding fields to the search, hacking the file isn’t needed if you are fine with the default matching method. See wet_haystack for automated index builder.
Rah-plugins | What? I’m a little confused… again :-)