Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By samchok on
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
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.
Thank you very
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. ;-)
How did you display the letter of each group?
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?
Help with custom field
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.
Aw.... so simple....
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
now that's what I call a clean solution
@Sourcery : well done !
used your technique and worked like a charm.
Thanks @ Sourcery
Very elegant
Many ways to the same ends...
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
Unfortunately, this method will not work for grouping all number-starting titles under one page.
I'll try using views_customfield for this...
organising taxonomy by Letter in D7
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.
Freelance Drupal Consultant
_
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.
Maybe this screencast will
Maybe this screencast will help: http://vimeo.com/21052075
for future ref.
Much appreciated!
Thank you so much!
Really simple way to create alphabetical index
Really :)?
When you're editing view:
Nice. Unfortunately this
Nice. Unfortunately this method does not handle grouping of numbers/special characters.
Thanks @jd this just did the
Thanks @jd this just did the trick for me for what I was trying to do on a listings page.
Thanks jd. It worked (for me
Thanks jd. It worked (for me too).
thanks
This is just what I was looking for, thanks!
Combing lowercase and uppercase letters
This is a great solution, unfortunately it doesn't account for casing of terms. For example, if there were the nodes
the output would be
a
A
Does anyone have any suggestions on how to solve this within views, or does this have to be solved in code?
Found a fix...
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.