Hi all,
I'm searching to create an alphabetical index of all my nodes of a specific content type using views. Anyway, all I can do with views is order all my nodes based on their title, but I also need to put a separator between each new starting letter. Something like this:

A
- August
- Auto

B
- Belgium
- Bed
- Bulgary

C
- Case study
- Citron
...

How can I get a result like that?

Thank you!

Comments

The only idea I have is to create 26 views (one for every letter of the alphabet) and display each of those views in the same page.
But it seems to me too long and complicated!

An idea I've been tossing around for this, is to try to use views_customfield to create a field that consists of the first letter of the title (using the substr php function), and then using that field to group the view style. I just haven't had a chance to try it yet. Otherwise, it's probably a matter of a custom view template.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Thank you very much!
Following your suggestion (grouping by customfield) did the trick.

awesome-- thanks for posting back, at least now we know it works. ;-)

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

I am trying to do this same thing. I have created the custom field and grouping works fine, but how do you display each of the grouping letters?

Hello,

Perhaps you could assist me by telling me how you did the custom field?

Since I havent gotten that far in this I dont know the exact answer to your question... Try this:

Use the Style: Unformatted, press the cogwheel, and choose groupfield: and choose your custom field as groupfiled.

Hello again....

This was SO much simpler than integrating a lot of PHP code et al.

What you do is you add another field node title (so you have TWO node title in fields). This field, you shirten down to length 1. You also exclude from view.

Then you choose style: unformatted, and then choose the second node title as the group field.

E Voila! :) Simple and beautiful list from A-Z.

Hope this helps everyone looking for this function.

/Kristian

@Sourcery : well done !
used your technique and worked like a charm.

---------------------------------------------
what we do in life echoes in eternity

Very elegant

First, sorry I fell off this thread, for the sake of completeness, I'm back to clear up my vague comment/question. I really like your method, creating a title with a length of one, brilliant!

My situation ended up being a little weird, as in some departments in my company seem to have funny ideas about alphabetical ordering, so I needed a way to allow them to change their alphabetizing letter.

I created a CCK field that is auto-filled with the first letter of the title of the node, but can be changed if it needs to appear somewhere else in the list... Think 'School of Education' appearing under the E instead of S... anyway.

Other than that I used the same method your describing and it worked very well. :)

Unfortunately, this method will not work for grouping all number-starting titles under one page.

I'll try using views_customfield for this...

It doesn't seem to work for me in D7.
When grouping with the trimmed 'term field' the letter appears on top of every term entry. I think because it only trims the 'view' but not the actual value of the term field. Although the letter 'A' repeats itself, the value behind it is each time different, so it appears each time on top of each individual taxonomy entry.

My solution is adding a 'category' selection field to the taxonomy, as is posible in D7, and use it as a grouping field. letter. You can use letters as grouping field or other categories.

Nuez Web

I got it working without an additional field no problem. You need to add the term field 2 times-- once excluded from display and trimmed to one character (use this for the grouping field) and once to actually display the term itself.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

Maybe this screencast will help: http://vimeo.com/21052075
for future ref.

Thank you so much!

Really :)?
When you're editing view:

  1. Prepare fields
    • in fields add new one field "The content title"
      • Uncheck "Create a Lable"
      • Check "Exclude from display"
      • in "REWRITE RESULTS"
        • Trim this field to a maximum length
          • Set "Maximum length" to 1
          • Uncheck "Add an ellipsis"
          • Uncheck "Trim only on a word boundary"
  2. Grouping
    • Change output format to "Grid" or "Table"
    • Configure output format and select "Grouping field Nr.1" your last added field

Nice. Unfortunately this method does not handle grouping of numbers/special characters.

Thanks @jd this just did the trick for me for what I was trying to do on a listings page.

--
Sumeet Pareek, Innoraft

Thanks jd. It worked (for me too).

This is a great solution, unfortunately it doesn't account for casing of terms. For example, if there were the nodes

  • apple
  • Ape
  • Alamo

the output would be

a

  • apple

A

  • Ape
  • Alamo

Does anyone have any suggestions on how to solve this within views, or does this have to be solved in code?

The fix I found was to use the termcase module http://drupal.org/project/termcase/
I would have liked to have found something that didn't require an extra module, but this works.