I have a huge list of companies (nodetype : company, only field is title) that I want to display in a nice way groupping them by first letter like a dictionnary like this :
A
Abc company
Alot of work company
B
Beautiful company
Best company
Trying to find a way to do it in an elegent way; no module seems to exist for that. Any idea ?
You don't really need to go down the code path to achieve this. You can see some of this described here: http://drupal.org/node/641342
Basically, add the node title to the view twice. The first is your normal field with links, etc. The second one is for the grouping.
The second field you mark to exclude from display, remove the label, and trim the field to a maximum length of 1 (uncheck the word boundary, ellipsis, and html options).
Then, under the "row style" options you'll find the "group by" setting, and you just select the second node title field.
You may need to apply additional theming if you want to have it look a certain way or possibly adding anchors for each letter, but otherwise that should work for version 6 of Drupal with views 2 module
Also, I should point out the group by module http://drupal.org/project/views_groupby which can offer some additional functionality but which isn't really needed for the original question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With