Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
sort numerically named sections despite lack of leading zeros?
I’ve got a bunch of sections which have been named like: thing1, thing2, thing3 … thing9, thing10, thing11.
I want to do txp:article_custom with sort=“section desc” and of course the lack of leading zeros is making them show up in the “wrong” order: thing1, thing10, thing11, thing2, thing3, etc.
Renaming the sections would be bad because there are plenty of links to URLs that include the section names. (Though if need be, I could use .htaccess to redirect.)
Any suggestions on the best solution for this?
Offline
Re: sort numerically named sections despite lack of leading zeros?
If ‘thing’ is the same for all sections and is 5 characters long, then try sorting like this sort="SUBSTR(section,6)+0"
. The SUBSTR returns all characters from the section name starting on position 6 and the +0 converts the string into a number to make sorting work.
Offline
Re: sort numerically named sections despite lack of leading zeros?
Worked perfectly—thanks, Ruud!!!
Offline