How to sort by last name in Content Profile?

kdipen's picture

Hi Team,

I'm using Content Profile for my Faculty list, and there is single line field for first and last name. I can only sort by first name since there is only one field for name. Now I would like to sort it by last name. Is there any way to sort by last name since I already have Views created.

If I create two fields for first and last names, how would I display full name in single line using Views?

Thanks in advance.


Yes you have to create 2

dmiric's picture

Yes you have to create 2 fields. And there is an option in views where you can override what is shown and you have tokens so you can do almost anything.

First you add last name to the fields that are to be displayed then you add first name and override it so it shows first than the last name. Its very easy to do.


I'd recommend breaking the

caschbre's picture

I'd recommend breaking the field into fname and lname, otherwise you won't really know what the last name is.

If you go that route, you can easily display the full name with views. The trick is to add both the fname and lname to the view display but don't set them to actually display. Then you can add a generic display field and overwrite the output to display the fname and lname.

3 fields

jct's picture

Everybody's posts here are correct, in my experience. Depending on the nature of the site, you might consider having 3 fields. The one you have currently might be the display name (aka "Real Name") that shows in posts, while the fields for the First/Last names can be used for sorting.

how to over write the output in Views

kdipen's picture

Thanks for your reply - Damir, Craig and John.

I created extra two fields for first name and last name. How would I over write the output in Views to NOT show in the faculty list, but use it only for sorting internally. Since there is already full name showing in the list.


Click on the field in the

caschbre's picture

Click on the field in the fields section and you'll see a list of options for that field. One of the first should be "Exclude from display". Just check that box and it won't be displayed.

Also... you don't need to have a field in the display section to use it in the sorting.


kdipen's picture

Thank you.
Great community support, it really helps.