3

I want to list all the posts with alphabetical headings like this site:

enter image description here

How can I do this with drupal 7 using views?

  • How did you group the listing alphabetically? – CocoSkin Nov 11 '14 at 16:00
  • @CocoSkin Are you asking about the image? I think it is from another website that the questioner did not create. – user1359 Nov 12 '14 at 20:24
3

You need to try this simple way, just create a view with views module:

  1. Advanced-> Contextual Filters-> Content: Title. If you click Content: Title, under "More" you will find the option to use upper or lower case when sorting the view. You got half of alphabetical list view just like A | B | C | D | F |......
  2. Create a another view for remaining half that group posts under alphabetical letter .
  3. Set Footer -> Configure Footer: Global: View area -> View to insert.
  4. Check half and half view on page or block.
10

Have you looked at the "Glossary" view? It is a sample view included with the views module that lists all site content by letter in a manner similar to the link you listed.

The "Glossary" view is disabled by default, but you can enable it on the views admin page (admin/structure/views).

The settings for sorting the posts in the "Glossary" view can be found on the views edit screen under Advanced-> Contextual Filters-> Content: Title. If you click Content: Title, under "More" you will find the option to use upper or lower case when sorting the view.

  • I was just typing the same thing... but you beat me to it :-) On-topic: If the glossary view is not exactly what you need, you can easily clone and edit it, for instance to add a filter on node type. – marcvangend Mar 9 '12 at 10:22
  • Yes I had a look at the glossary view and it does half of what I need. The thing is it doesn't group posts under the Capital Letters. How to add that? – Ruriko Mar 9 '12 at 10:27
  • I added some information to my answer about sorting the posts. If you need more information, please be more specific about what you want to do. – Patrick Kenny Mar 9 '12 at 10:52
  • Any idea why this doesn't work when using solr + search_api + search_Views? – Andrew Welch Feb 7 '13 at 12:31
  • @AndrewWelch No, you're on your own with such a complex configuration. – Patrick Kenny Feb 7 '13 at 13:09
1

This new module might be helpful: https://www.drupal.org/project/alpha_pagination

It uses the glossary functionality that Patrick Kenny mentioned but it extends that in super-powerful and useful ways.

From the module page: The Alpha Pagination for Views module enables you to add an alphabetical menu in the header or footer of a views display.

Dependencies Views

Install Install the Alpha Pagination module.

Copy the alpha_pagination folder to the modules folder in your installation. Download and enable dependencies (views and views_ui). Enable the Alpha Pagination for Views module using Administer -> Modules (/admin/build/modules). Views Integration and Configuration

Build a new view of either users, content (nodes), or comments. Add whatever field you want to use as the basis for the alphabetic grouping (e.g. title, body). You can optionally exclude this field from display if you don't want it to appear in the results shown on the page for some reason. You can only choose a field that is a textfield, textarea or a textarea with a summary.

Add either a header or a footer to your view. Select the new item available in the menu of options for Global: Alpha Pagination.

Configure how you want alpha_pagination to work and specify where it should appear: set the path to the results view page.

select the field you want to use as the basis for the alphabetic grouping from the options presented in the select list (note: if the field you want to use does not appear, go back and add it to your view and then return to this configuration page to select the field).

add a context that is the same as the field you wish to use as the basis for alphabetic sorting. Be sure to enable Glossary mode and set the character limit to 1. The transform case option on the URL should be set to Upper Case.

by default the alpha pagination will apply to all displays; if you only want the alpha pagination to appear on the current display, use the drop-down menu at the top of the administrative interface to change the setting from "All displays" to "This page (override)".

An optional sample view is included and can be enabled via the alpha_pagination_example view. The sample relies on the 'article' default content type. You can create sample content using the devel module or rely on your own data.

This module exists thanks to the support of Highwire Press, Inc. and the Institute for the Arts and Humanities and UNC and was created as part of the Symposiac Conference Platform.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.