New plugin: Name Wrangler
Posted: 25 October 2009 11:46 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  289
Joined  10-05-2007

I seem to work on a lot of sites with one or more weblogs consisting of entries as people.  Often I’m asked to display these entries in alphabetical order by last name, but display the names in proper order.  I wrote Name Wrangler to address this, and add some other perks to working with proper names as well.

Name Wrangler lets you use proper names in the format SURNAME, GIVEN NAME in the back-end (in order to faciliate proper sorting), but still display them in the the format GIVEN NAME SURNAME. It also allows you to display first, middle, and last names independently, in both singular and posessive forms, and to do this with both individual names and lists of ampersand-separated names.

Parameters:

- type: the type of name(s) to return. Either “full”, “first”, “middle”, “first+middle”, or “last”.  Defaults to “full”.
- form: either “singular” or “posessive”. Defaults to “singular”.
- and: word or character entity to use before the last name at the end of a list of names.  Defaults to “&”.

Example use:

{exp:name_wrangler}HedgesChris{/exp:name_wrangler} consistently impresses me with his writing and journalism

Returns “Chris Hedges consistently impresses me with his writing and journalism.”

{exp:name_wrangler type="first" form="posessive"}HedgesChris{/exp:name_wrangler} latest book is a sobering read

This returns “Chris’ latest book is a sobering read.”

{exp:name_wrangler type="last"}HedgesChris MooreAlan RobinsonKim Stanley{/exp:name_wrangler} are very differentbut all must-read authors

This returns “Hedges, Moore & Robinson are very different, but all must-read authors.”

Hope folks find this useful!

UPDATE: Version 1.0.1 adds middle-name awareness.

Download Name Wrangler from GitHub

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

Profile
 
 
Posted: 25 October 2009 12:55 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  06-12-2002

Any way to extend this to also work with the Screen Name field in the Members module?

Profile
 
 
Posted: 25 October 2009 12:58 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  289
Joined  10-05-2007

Adrienne - you can use this on any string of text anywhere that plugins can be called.  Not sure if plugins are available within member profile templates, but if so, then yes, you can use Name Wrangler.

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

Profile
 
 
Posted: 25 October 2009 01:36 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  06-12-2002

Yeah, I see that. Here’s the thing: usually people put their screen name in as First Last.

So i’m wondering if there can be a way to configure the plugin to tell it “this is a name in last, first format” or “this is a name in first last format”.

Profile
 
 
Posted: 25 October 2009 02:10 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  289
Joined  10-05-2007

Adrienne - Name Wrangler will still work its magic for grabbing first and last names - and generating possessive forms - with forward-written names.  If it doesn’t find that comma, it doesn’t do any transposing.

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

Profile
 
 
Posted: 25 October 2009 03:08 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  232
Joined  06-12-2002

Sweet! You’re just awesomely clever then. smile Next you’ll tell me it has a cool regex for handling middle names and initials, and then my life will be utterly complete. wink

Profile
 
 
Posted: 26 October 2009 02:31 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  289
Joined  10-05-2007

Just updated to version 1.0.1 to add awareness of middle names. You can now pass “middle” or first+middle” in the “type” parameter. Multiple middle names are treated as one string, so “Johnson, Billy Jack Wensdale” would return “Jack Wensdale” as the middle name.

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

Profile
 
 
Posted: 01 February 2010 01:07 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  146
Joined  04-17-2006

This is a game changer.

For so long, I’ve added an extra custom field to just hold the last name of the person listed in the title field (or elsewhere.) When I saw this plugin on Devot:ee, thanks to my curiosity and Google, I thought, well great, but I don’t want to go in and update all those name fields on all those sites to bring in this elegant solution.

And then… http://expressionengine.com/forums/viewreply/657368/

You are the man. Thank you!

Any future version going to take into account suffixes like Jr., Sr., III, etc.?

 Signature 

http://davidrussell.net | http://twitter.com/davidrussell

Profile
 
 
Posted: 13 February 2010 07:11 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  157
Joined  01-14-2009

Is there a way to turn the “and” parameter off? I have a site with a list of bands and some of them are named things that are throwing this out of whack. For instance:

The Fresh & Onlys is entered into the backend as Fresh & Only’s, The

Name wrangler turns it into “Fresh & The Onlys”

Also, for a band like The Lovin’ Spoonful

The ampersand in the html encoding for a single quote turns that into Lovin & The Spoonful

Anything I could change to the plugin code to get this feature to turn off?

Profile
 
 
Posted: 14 February 2010 11:33 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  289
Joined  10-05-2007

Funny enough, I just caught the issue with the encoded entities myself the other day.  Just pushed an update to GitHub to fix this, and also added a new parameter “multiple”, which can be set to “off” to ignore ampersands as indicators of multiple names in a string.

 Signature 

Amphibian Design | @devot:ee | GitHub | Twitter | EE Pro Network

Profile
 
 
Posted: 15 February 2010 11:43 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
RankRank
Total Posts:  157
Joined  01-14-2009

That’s awesome! Totally fixed my issue. Thanks!

Profile
 
 
Posted: 16 February 2010 02:07 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  146
Joined  04-17-2006

I think I preferred the band names the way Name Wrangler sliced them. I mean, who wouldn’t go see “Lovin’ and the Spoonful” play? Sounds awesome.

 Signature 

http://davidrussell.net | http://twitter.com/davidrussell

Profile