How to make Alphabetical listing ?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
tejaspmehta's picture

Hello Everyone,

I have created one view based on some filters, now its working fine.

As per requirement, i want to create like following

A | B | C | D | ............. | Y | Z

[view data here]

What i want to do is...
-> i have to create one line which contains alphabets.
-> If i click on "B" then all data started with 'B' will be displayed with or without pagination.

Can anyone provide idea that how to make this working ?

Thank you
Tejas Mehta

Comments

This is called a glossary

Maedi's picture

This is called a glossary view.

  1. Add an argument 'Node: Title'
  2. Select 'Provide default argument'
  3. Select 'Fixed entry'
  4. Type 'a' in the default argument field
  5. Tick 'Glossary mode' and set character limit to 1

Hello Maedi, Thank you for

tejaspmehta's picture

Hello Maedi,

Thank you for your quick response. I followed your step and it display some records. Now can you let me know how to display following line at top of view ?

A | B | C | D | ....... | Y | Z

Here on every character it must be hyperlink.

waiting for your response.

Thank you
Tejas Mehta

Here's an export of my view

Maedi's picture

Here's an export of my view (http://macintoshgarden.org/games). I think the Letter navigation appears automatically for me.

<?php
$view
= new view;
$view->name = 'games_a_to_z';
$view->description = 'A list of all games, by letter.';
$view->tag = 'games';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
 
'body' => array(
   
'label' => '',
   
'alter' => array(
     
'alter_text' => 0,
     
'text' => '',
     
'make_link' => 0,
     
'path' => '',
     
'alt' => '',
     
'prefix' => '',
     
'suffix' => '',
     
'help' => '',
     
'trim' => 0,
     
'max_length' => '',
     
'word_boundary' => 1,
     
'ellipsis' => 1,
     
'html' => 0,
    ),
   
'exclude' => 0,
   
'id' => 'body',
   
'table' => 'node_revisions',
   
'field' => 'body',
   
'relationship' => 'none',
  ),
 
'field_screenshot_fid' => array(
   
'label' => 'Screenshot',
   
'alter' => array(
     
'alter_text' => 0,
     
'text' => '',
     
'make_link' => 0,
     
'path' => '',
     
'alt' => '',
     
'prefix' => '',
     
'suffix' => '',
     
'help' => '',
     
'trim' => 0,
     
'max_length' => '',
     
'word_boundary' => 1,
     
'ellipsis' => 1,
     
'html' => 0,
    ),
   
'link_to_node' => 0,
   
'label_type' => 'widget',
   
'format' => 'thumbnail_linked',
   
'multiple' => array(
     
'group' => 1,
     
'multiple_number' => '',
     
'multiple_from' => '',
     
'multiple_reversed' => 0,
    ),
   
'exclude' => 0,
   
'id' => 'field_screenshot_fid',
   
'table' => 'node_data_field_screenshot',
   
'field' => 'field_screenshot_fid',
   
'relationship' => 'none',
  ),
 
'teaser' => array(
   
'label' => 'Teaser',
   
'alter' => array(
     
'alter_text' => 0,
     
'text' => '',
     
'make_link' => 0,
     
'path' => '',
     
'alt' => '',
     
'prefix' => '',
     
'suffix' => '',
     
'help' => '',
     
'trim' => 0,
     
'max_length' => '',
     
'word_boundary' => 1,
     
'ellipsis' => 1,
     
'html' => 0,
    ),
   
'exclude' => 0,
   
'id' => 'teaser',
   
'table' => 'node_revisions',
   
'field' => 'teaser',
   
'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
 
'title' => array(
   
'order' => 'ASC',
   
'id' => 'title',
   
'table' => 'node',
   
'field' => 'title',
   
'override' => array(
     
'button' => 'Override',
    ),
   
'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
 
'title' => array(
   
'default_action' => 'default',
   
'style_plugin' => 'default_summary',
   
'style_options' => array(),
   
'wildcard' => 'all',
   
'wildcard_substitution' => 'All',
   
'title' => '',
   
'default_argument_type' => 'fixed',
   
'default_argument' => '',
   
'validate_type' => 'none',
   
'validate_fail' => 'not found',
   
'glossary' => 1,
   
'limit' => '1',
   
'case' => 'upper',
   
'path_case' => 'lower',
   
'transform_dash' => 0,
   
'id' => 'title',
   
'table' => 'node',
   
'field' => 'title',
   
'relationship' => 'none',
   
'default_argument_user' => 0,
   
'default_argument_fixed' => 'a',
   
'default_argument_php' => '',
   
'validate_argument_vocabulary' => array(),
   
'validate_argument_type' => 'tid',
   
'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
 
'type' => array(
   
'operator' => 'in',
   
'value' => array(
     
'game' => 'game',
    ),
   
'group' => '0',
   
'exposed' => FALSE,
   
'expose' => array(
     
'operator' => FALSE,
     
'label' => '',
    ),
   
'id' => 'type',
   
'table' => 'node',
   
'field' => 'type',
   
'override' => array(
     
'button' => 'Override',
    ),
   
'relationship' => 'none',
  ),
 
'status' => array(
   
'operator' => '=',
   
'value' => '1',
   
'group' => '0',
   
'exposed' => FALSE,
   
'expose' => array(
     
'operator' => FALSE,
     
'label' => '',
    ),
   
'id' => 'status',
   
'table' => 'node',
   
'field' => 'status',
   
'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
 
'type' => 'none',
 
'role' => array(),
 
'perm' => '',
));
$handler->override_option('cache', array(
 
'type' => 'none',
));
$handler->override_option('title', 'Games A - Z');
$handler->override_option('header_format', '1');
$handler->override_option('header_empty', 0);
$handler->override_option('footer_format', '3');
$handler->override_option('footer_empty', 0);
$handler->override_option('items_per_page', 30);
$handler->override_option('use_pager', '1');
$handler->override_option('style_options', NULL);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
 
'teaser' => 1,
 
'links' => 0,
 
'comments' => 0,
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('path', 'games');
$handler->override_option('menu', array(
 
'type' => 'normal',
 
'title' => 'Games A - Z',
 
'description' => '',
 
'weight' => '0',
 
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
 
'type' => 'none',
 
'title' => '',
 
'description' => '',
 
'weight' => 0,
 
'name' => 'navigation',
));
$handler = $view->new_display('attachment', 'Attachment', 'attachment');
$handler->override_option('arguments', array(
 
'title' => array(
   
'default_action' => 'summary asc',
   
'style_plugin' => 'unformatted_summary',
   
'style_options' => array(
     
'count' => 1,
     
'override' => 0,
     
'items_per_page' => '25',
     
'inline' => 1,
     
'separator' => ' | ',
    ),
   
'wildcard' => 'all',
   
'wildcard_substitution' => 'All',
   
'title' => '',
   
'default_argument_type' => 'fixed',
   
'default_argument' => '',
   
'validate_type' => 'none',
   
'validate_fail' => 'not found',
   
'glossary' => 1,
   
'limit' => '1',
   
'case' => 'upper',
   
'path_case' => 'lower',
   
'transform_dash' => 0,
   
'id' => 'title',
   
'table' => 'node',
   
'field' => 'title',
   
'relationship' => 'none',
   
'default_argument_user' => 0,
   
'default_argument_fixed' => 'a',
   
'validate_argument_vocabulary' => array(),
   
'validate_argument_php' => '',
  ),
));
$handler->override_option('attachment_position', 'before');
$handler->override_option('inherit_arguments', 0);
$handler->override_option('inherit_exposed_filters', FALSE);
$handler->override_option('inherit_pager', FALSE);
$handler->override_option('render_pager', TRUE);
$handler->override_option('displays', array(
 
'default' => 'default',
 
'page' => 'page',
));
?>

You can create a block which

freeform.steph's picture

You can create a block which displays on only that page, with links containing the appropriate arguments. Alternatively, you can create a second display in your view of type block if you want to limit the list to only the alphabetic letters which contain content.

okay got idea. but what will

tejaspmehta's picture

okay got idea. but what will be in argument ? i tried few options but none of them work. if you can give one example then it will be helpful.

i tried following.
http://mysite/listing_by_alphabets?c
or
http://nealserver/wtcadev/wtc_by_alphabets?arg=d

just a little more help

Thank you
Tejas Mehta

I believe url would be:

freeform.steph's picture

I believe url would be: http://mysite/listing_by_alphabets/c

And in your view, set the path to "listing_by_alphabets/%"

use /

got the idea. it worked now.

tejaspmehta's picture

got the idea. it worked now. i added manually A...Z in view Header section and it worked for me.

Thank you everyone for your help and time.

Thank you
Tejas Mehta

What type of manuval code u have entered ?

Ravi Shankar Karnati's picture

What type of manuval code u have entered for Alpha betical pagination , Plz help me, am in trouble, i plz guide me in detail...

waiting for ur response...., my mail id is pamidipadudravid@gmail.com

Thanks in advance

hmdnawaz's picture

I have added the letters manually in header section of the view but how can I get it as links? Because it is only alphabets and not clickable. How you did this?

am following this

Ravi Shankar Karnati's picture

am following this link

http://tedserbinski.com/tags/drupal/creating-alpha-pager-with-views-2-an...

and add the following code in header

.

. A
. B
...
.

in arguments , Set title equal to: “Directory: %1”

plz guide me

The first comment in this

recidive's picture

The first comment in this post is all you need, you don't need to manually add the alpha pager. In Views 3, 'arguments' was renamed to 'contextual filters'. Check the glossary default view that ships with views module for an example.

i cant get u ..

Ravi Shankar Karnati's picture

recidive Sorry i cant get u, actually am using drupal 6 with views 2 versions, i already did the some progress in my project, so plz guide me clearly with steps , am some poor in drupal, plz guide me.....waiting for ur response.. Thanks in advance..

Incorrect

earwax's picture

You are incorrect. Simply enabling the glossary option does not give you the alphabetized links (e.g. A | B | C | D etc...)

How can you get the link?

Jegan2668's picture

I have added the letters manually in header section of the view but how can I get it as links? Because it is only alphabets and not clickable. How you did this?

clayball's picture

An A-Z pager is required for the views attachment. This is included in the included Glossary View and is Attached To the Master and Page.
So to use this in a Block you will need to add the Block to the Attachment -> Attached To setting. This wasn't obvious!

Alphabet pager with all letters

ibakayoko's picture

How to implement something like this pager
http://nanwich.info/glossary with views 3 (drupal7)

I have looked at the Gloassary views but i was not able to find how to display all the letters of the alphabet.

I want the same

tajinder.minhas's picture

i want the same diaplay as described by ibakayoko(http://nanwich.info/glossary ) i am scratching my head from last four hours but couldn't find the solution

Please if anyone ca help

Regards
Tajinder Singh Minhas

help with glossary

justluvgod's picture

I have a couple of questions. I am using Glossary to create a site map. I have mostly everything working the way I want except I would like to remove the numbers next to the letters at the top of the page.

Also something unexpected. I excluded a content type "employee" when I did a filter. None of the employees names appear (as it should) but the alphabetical listing at the top appears as if there is data related to the employees in there and there isn't.
Any idea why this is so?

help with glossary update

justluvgod's picture

I was able to resolve how to remove the (count) next to the alphabetical listing using glossary view.

I made a copy of the views-view-summary-unformatted.tpl.php and copied it to my subtheme in the templates folder.

I then commented out the (

<?php
print $row->count;
?>
) line and saved the document. I then went to Drupal and flushed all of the caches and it seem to work. All of the (count) next to the letters are gone.

Alas, I still have the second issue regarding the employee filter.

Any assistance would be greatly appreciated.

I have spent all afternoon

wipeout_dude's picture

I have spent all afternoon trying to get this working..

I can get it to work for the "all" display but as soon as I click on a letter I get two displays (one above the other) of the items that start with that letter.. The glossary index line seems to change to a list..

Tried to check settings against the "glossary" example but couldn't see where I was going wrong.. Must be missing something..

Here is your solution

quwat's picture

For this you have to play with the Views attachments and here is the view setting that will give the result you want.

Basic Settings

  1. Display Status: Enabled
  2. Items to display: All Items

Advaced Settings

  1. Use AJAX: Yes
  2. Use grouping: No
  3. Query settings: Settings
  4. Caching: None

Style Setting

  1. Style: Unformatted
  2. Row style: Node

Exposed Form

  1. Basic

Attachment Settings
2. Attachment to Block/Page/Multiple Pages
3. Position before or after

Argument

  1. Tick Glossary Mode
  2. Character limit 1
  3. Validator should be set to Basic
  4. Save.
    In argument Choose Style Unformatted.
    Update and Choose: Display Items inline
    Choose the Seperator as ‘|’ which you wanted.

Save and you are done.
Check here http://www.yasinvalley.com/glossary

Steps

krazykellie's picture

Hey Quwat,

I am trying to follow these steps for Drupal 7 in Views and am aware that Argument is now Contextual filters, but I do not have a "Glossary Mode" listed. Is there something else that I should have installed to make this work?

a solution

giacy86's picture

i wrote an easy function for alphabetical pager. At this page, http://geekandhack.iblogger.org/paginazione-in-ordine-alfabetico-drupal-... there is the code and the example (in italian language). Here, http://tagmovies.it/actor there is a demo that i've implemented.

Creating a Glossary page

ashutosh@rana's picture

Steps to follows:-
1./ Create a view with page to show desired content type
2./ click on CONTEXTUAL FILTERS
3./ add content title
4./ Select this page override
5./ Select Provide default value and type fixed value
6./ Enter "a" for default display only "a" word containing content and enter "all" for default display "all" content
7./ select Specify validation criteria:Basic
8./ Click More AND check Glossary mode option
9./ Set Character limit 1
10./ save
11./ Use Ajax "yes"

Now add a attchment
1./ click on CONTEXTUAL FILTERS
2./ add content title
3./ Select this attachment override
4./ click Display a summary
a./ Click Display items inline
b./ seperator - or |
5./ Set Attach to: page From ATTACHMENT SETTINGS
5./ Set Inherit contextual filters: NO From ATTACHMENT SETTINGS
6./ Use Ajax: Yes
7./ Now save and run the page

========DONE=======

This new module might be

knowledges33ker's picture

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.

yellow pages

MarketStone's picture

so i have a glossary and want to add terms like Airplane, Automobile. The content type has the taxonomy reference field to choose Airplane or Auto. is the best way to do this is add attachments to each letter? And would You stat the view in "show content" or show Taxonomy terms. Thanks for any time.

views can do this but will check out alpha_pagination

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week