I built a CCK content type for an address book (last name, first name, phone etc). I then built a view (page display) to show these nodes, sorted by last name. How can I group the output by first letter of the last name (A, B, C etc) and then by last name itself within these groups? Thanks!

Comments

i25’s picture

Any ideas on this one guys? Thanks.

timnorman’s picture

Do you mean just using the sorting function to sort the items? You can do a lot in the sorting section of views. You could tell views to sort your list based on the last name (last name is a separate field, right? otherwise I don't think you could do this.).

If you are looking to be able to click on A, B, C etc. and then get those names under that letter... I haven't done this myself but I'm thinking that you would create a sort based on the first letter and expose that sort to the user.

i25’s picture

I'm already sorting based on the last name field, but the only options I have for sorting are Ascending and Descending. Do you know where I would find options for sorting on first letter?

timnorman’s picture

I'm sorry I should have said filter. You create a filter and expose that to the user. The A, B, C etc would be filters. As I said I haven't done this, but I believe it is possible.

I took a look at this quickly. There may be a better way than what I'm doing, but you should be able to create a filter on your last name field and tell the operator to "Starts with". You would expose this to the user and you could even expose the operator to the user so they could define it more for themselves.

Not how I originally envisioned it, but I know I've seen an A, B, C list and just clicked on that letter to filter out the content. I'd play around in that area to see what else is possible.