Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-10-18 13:03:30
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
[request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Hello
I’m looking for a way to show an alphabetical index of article titles where a list of Book/Film/Play titles like:
- An Outrage in Clonrickart
- A Very Tasty Breakfast
- Away on a Hack
- The Seven-sided Sausage
- Away on a Hack
- Outrage in Clonrickart, An
- Seven-sided Sausage, The
- Very Tasty Breakfast, A
I’m currently achieving it by providing a custom field where the adjusted title has to be manually input but think it would be great if there was a plug-in to automate it.
Is it possible? has it been done? Anyone interested in creating it?. A great version would be one that could be configured to work for other languages also.
thanks all
Last edited by woof (2009-10-18 13:16:41)
Offline
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
I take you mean this for public-side use? It would probably be easy enough for me to adapt soo_article_filter to do this. Might have a noticeable performance impact, though, for a site with a lot of articles.
Edit, Feb 19 2010: soo_article_filter now has this feature.
Last edited by jsoo (2010-02-19 18:07:32)
Code is topiary
Offline
#3 2009-10-18 13:45:10
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Hi Jeff, thanks for your reponse
Yes it is for public-side. I would use it to produce a complete alphabetical index of articles, similar to a traditional publisher’s index. Potentially it could be asked to handle a great many articles but in my particular case I reckon 400—600.
Offline
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Although I don’t think it will reorder the titles as you’re hoping for, if all else fails chh_article_custom has an titlearticles
attribute which you can use to specify words like ‘an’ and ‘the’ that you want the sort order to ignore.
Offline
#5 2009-10-18 13:56:29
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Hi Stuart
Thanks – that sortby="SmartTitle"
looks promising for covering the sort aspect of what I need
Offline
#6 2009-10-18 14:30:11
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Ok I’ve thought about it a bit and I think a perfectly workable solution for me is to use chh_article_custom
’s sortby="SmartTitle"
attribute to sort the articles “properly” and use if_custom_field
in the list form to swap in a manually created adjusted title in place of <txp:title/> in those instances where one is needed.
Thanks Jeff and Stuart
Probably an overambitious wish but wouldn’t it be awesome to have a dedicated plugin to generate rich indexes like its done in print-based publishing, with separate divs and titles for each letter or letter grouping of the alphabet and not just article titles but also incorporating tags/keywords, image references…
Offline
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Instead of a custom field, replace title
with this:
<txp:php>
echo preg_replace('/^(a|an|the) (.+)/i', '$2, $1', title(array()));
</txp:php>
Edit: simpler
Last edited by jsoo (2009-10-18 15:02:27)
Code is topiary
Offline
#8 2009-10-18 15:19:39
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Wonderful – thanks so much Jeff
Offline
#9 2009-10-18 21:22:21
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
Another one for the toolbox. Thanks, Jeff!
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
A quick update to my chh_article_custom suggestion – it doesn’t work in 4.2.0. Jeff’s tip is the best option I can see.
woof – did it work for you?
Offline
#11 2009-11-10 14:31:23
- woof
- Member
- Registered: 2004-08-01
- Posts: 128
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
pieman wrote:
woof – did it work for you?
yes chh_article_custom version 1.15 works fine for me in TXP 4.2.0
IIRC I couldnt get Jeff’s code snippet above to work for me so I forged ahead using a manually input reordered title in a custom field
This works for me
<txp:chh_article_custom section="programmes" time="any" form="default" listform="film_listing" limit="999" sortby="SmartTitle" sortdir="asc" titlearticles="A,An,The" />
with the following in the listform to display either the article title or – if one exists – the custom field with reordered title :
<txp:if_custom_field name="index_or_alt_title"><txp:custom_field name="index_or_alt_title"/><txp:else/><txp:title/></txp:if_custom_field>
Offline
Re: [request] Ignore indefinite and definite article (a/an/the) when sorting titles?
I just ran in to the same problem with my site. Jsoo’ php fix works brilliantly, except in my case I’m using jQuery tablesorter to list the articles in my archive. So the titles do display properly with “the” at the end after a comma, but the table doesn’t sort them correctly.
I’m thinking this might require a fairly complicated fix so perhaps I should use something other than tablesorter.
Offline