[Owncloud] [Contacts] Hack for sorting by last name

Thomas Tanghus thomas at tanghus.net
Thu Aug 1 09:28:28 UTC 2013


On Wednesday 31 July 2013 13:02 Andreas Borutta wrote:
> Hi.
> 
> In version 5.0.9 it's not possible to sort by last name.
> When I got it, that feature should arive in version 6.
> 
> Because sorting by last name is important for me:
> Do you know a working hack of config files to realize that sorting
> now?
> 
> There's an old post with a suggestion for an older version of OC:
> http://forum.owncloud.org/viewtopic.php?f=4&t=6755
> 
> But I'm not a programmer and do not know which code has to be
> replaced.
> 
> If anyone could give me a hint ...?

You could change getDisplayName() at 
https://github.com/owncloud/apps/blob/stable5/contacts/js/contacts.js#L29
to return the values from the N property instead of the FN property.

Both are explained here: https://tools.ietf.org/html/rfc2426#section-3.1

The N property is an array btw.

getDisplayName() could return something like:

this.getPreferredValue('N', [this.getPreferredValue('FN','')])
  .slice(0, 2).join(', ');

That way it would return the comma-separated "lastname, firstname" or the 
formatted name if the N property doesn't exist.

You would get an error if neither of them exists though.

-- 
Med venlig hilsen / Best Regards

Thomas Tanghus



More information about the Owncloud mailing list