Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-26 17:49:39

Rachel Rachel
Member
Registered: 2004-09-24
Posts: 28

...ignore first 'The' in alphabetical list of titles?

okay, so i have a list of articles sorted alphabetically by title, but i want to be able to have the titles that begin with ‘The’ be sorted as if the ‘The’ weren’t there (without having to change the titles to ‘Boondock Saints, The’ or whatever), kinda like how in itunes, the alphabetical list of artists ignores the first ‘The’ in band names.

is this possible?

Offline

#2 2005-12-27 00:14:42

takshaka
Archived Plugin Author
From: Below the Manson-Nixon line
Registered: 2004-06-02
Posts: 97
Website

Re: ...ignore first 'The' in alphabetical list of titles?

It’s possible, but you’ll have to keep two sets of titles.

  1. Go to <code>Admin > Preferences > Advanced Preferences</code> and add a custom field named ‘Sort Title’ or something like that. For this example, let’s use custom field #10.
  2. Edit each article (yes, all of them), and copy the article title into the Sort Title field, removing a, an, the, and whatever else you want to ignore.
  3. On your page template, use an article/article_custom tag with the sortby attribute set to the custom field you added: <code><txp:article sortby=“custom_10” sortdir=“asc” /></code>.

You can speed up step 2 if you have access to a mysql client or phpMyAdmin where you can enter SQL directly to copy the titles to the custom field (<code>UPDATE textpattern SET custom_10 = Title WHERE section = ‘movies’</code>). Then the only articles you have to edit directly are those with titles you want to change.

Offline

#3 2005-12-27 02:59:38

Rachel Rachel
Member
Registered: 2004-09-24
Posts: 28

Re: ...ignore first 'The' in alphabetical list of titles?

oh, that’s what i was afraid of. ah well, such is life. thanks for the response.

Offline

#4 2005-12-27 11:08:08

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: ...ignore first 'The' in alphabetical list of titles?

There is another way, but you would need some PHP. Enter the title with (the) at the end, then when it’s displayed by Textpattern use PHP to test the string, delete it and add “The” at the begining of the title.

Offline

#5 2005-12-27 17:13:59

takshaka
Archived Plugin Author
From: Below the Manson-Nixon line
Registered: 2004-06-02
Posts: 97
Website

Re: ...ignore first 'The' in alphabetical list of titles?

It can be done with straight SQL and no extra column, but not with the core tags. I’ve tested the feature in the dev branch of chh_article_custom. If I have time today, I’ll release a new version.

Offline

#6 2005-12-27 20:51:27

takshaka
Archived Plugin Author
From: Below the Manson-Nixon line
Registered: 2004-06-02
Posts: 97
Website

Re: ...ignore first 'The' in alphabetical list of titles?

I seem to have more free time than expected, so the chh_article_custom 1.03 plugin is available. It can now trim leading articles — or any other specified words — from titles for sorting purposes.

<code><txp:chh_article_custom listform=“form” sortby=“SmartTitle” sortdir=“asc” /></code>

Offline

#7 2005-12-29 02:12:08

Rachel Rachel
Member
Registered: 2004-09-24
Posts: 28

Re: ...ignore first 'The' in alphabetical list of titles?

> takshaka wrote:

> I seem to have more free time than expected, so the chh_article_custom 1.03 plugin is available. It can now trim leading articles — or any other specified words — from titles for sorting purposes.

hey, cool! but where do i specify that i want a’s and the’s trimmed?

Offline

#8 2005-12-29 03:41:34

takshaka
Archived Plugin Author
From: Below the Manson-Nixon line
Registered: 2004-06-02
Posts: 97
Website

Re: ...ignore first 'The' in alphabetical list of titles?

I haven’t updated the online docs, but it is in the plugin help. Use the titlearticles (yeah, sad name) attribute to specify a comma-separated list of case-sensitive words.

The default is <code>titlearticles=“A,An,The”</code>.

Offline

#9 2006-01-05 23:06:46

Rachel Rachel
Member
Registered: 2004-09-24
Posts: 28

Re: ...ignore first 'The' in alphabetical list of titles?

takshaka – you rock.

thanks so much!

if anyone wants to see the plugin in action, i’ve got it running here

it’s so simple… (a la hansel in zoolander)

Offline

Board footer

Powered by FluxBB