Not sure if this is posted in the right forum, feel free to move it if need be.
I know a lot of people are after a Views Glossary page to display taxonomy terms, and from looking on the forum i have realised a lot of people are having trouble creating such a View thats in working order,
So i have created one for you to use if you need to, this was created on Drupal 6 using Views 2.
Heres a little description of the layout i used and a screen shot of the final view is included as well as the code used (you can use the code to import into views).
Image: Click to see the image
Basically, my site is a music site, a person uploads a music file and they Provide the node with an ARTIST name in a freetagging taxonomy field.
The tags for all songs uploaded to the site are saved under ARTIST (field_artist_tax). Users can then select an artist from the taxonomy list and clicking on it will provide them with all the songs related to that artist.
What my views does, is it provides a page where a user can click on a letter, and the views uses Ajax to display without refresh all the taxonomies beginning with that letter: (look at the image provided)
And here is the code: :)
$view = new view;
$view->name = 'gloss_temp';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'term_data';
$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(
'name' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_taxonomy' => 1,
'exclude' => 0,
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'name' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'ignore',
'glossary' => 1,
'limit' => '1',
'case' => 'upper',
'path_case' => 'lower',
'transform_dash' => 0,
'add_table' => 0,
'require_value' => 1,
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => 'a',
'default_argument_user' => 0,
'default_argument_image_size' => '_original',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'audio' => 0,
'faq' => 0,
'image' => 0,
'artistpage' => 0,
'event' => 0,
'music' => 0,
'page' => 0,
'profile' => 0,
'story' => 0,
'video' => 0,
'webform' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'5' => 0,
'8' => 0,
'9' => 0,
'10' => 0,
'6' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_node_flag_name' => '*relationship*',
'validate_argument_node_flag_test' => 'flaggable',
'validate_argument_node_flag_id_type' => 'id',
'validate_argument_user_flag_name' => '*relationship*',
'validate_argument_user_flag_test' => 'flaggable',
'validate_argument_user_flag_id_type' => 'id',
'image_size' => array(
'_original' => '_original',
'thumbnail' => 'thumbnail',
'preview' => 'preview',
'thumb_scale' => 'thumb_scale',
),
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'vid' => array(
'operator' => 'in',
'value' => array(
'8' => '8',
'9' => '9',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'vid',
'table' => 'term_data',
'field' => 'vid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Music By Artist');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 54);
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
'grouping' => '',
'columns' => '6',
'alignment' => 'horizontal',
'fill_single_line' => 1,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'music/by/name');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'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_1');
$handler->override_option('arguments', array(
'name' => array(
'default_action' => 'summary asc',
'style_plugin' => 'unformatted_summary',
'style_options' => array(
'count' => 0,
'override' => 0,
'items_per_page' => '25',
'inline' => 1,
'separator' => '|',
),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'glossary' => 1,
'limit' => '1',
'case' => 'upper',
'path_case' => 'lower',
'transform_dash' => 1,
'add_table' => 0,
'require_value' => 1,
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => 'a',
'default_argument_user' => 0,
'default_argument_image_size' => '_original',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'audio' => 0,
'faq' => 0,
'image' => 0,
'artistpage' => 0,
'event' => 0,
'music' => 0,
'page' => 0,
'profile' => 0,
'story' => 0,
'video' => 0,
'webform' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'5' => 0,
'8' => 0,
'9' => 0,
'10' => 0,
'6' => 0,
'4' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_node_flag_name' => '*relationship*',
'validate_argument_node_flag_test' => 'flaggable',
'validate_argument_node_flag_id_type' => 'id',
'validate_argument_user_flag_name' => '*relationship*',
'validate_argument_user_flag_test' => 'flaggable',
'validate_argument_user_flag_id_type' => 'id',
'image_size' => array(
'_original' => '_original',
'thumbnail' => 'thumbnail',
'preview' => 'preview',
'thumb_scale' => 'thumb_scale',
),
'validate_argument_php' => '',
),
));
$handler->override_option('attachment_position', 'both');
$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(
'page_1' => 'page_1',
'default' => 0,
));
Comments
forgot to mention, the views
forgot to mention, the views will not provide letters if there are no terms associated with a letter
also if you have a term available but there are no nodes under it then it will still be visible
thanks very much. I was
thanks very much. I was struggling a bit there. Works a treat straight out the tin.
Your welcome :)
Your welcome :)
Many thanks!
Oh my God, you saved my life. I've been banging my head against the desk here for hours and couldn't get this working. Wish I'd searched for a pre-made view in the first place. Funny thing is I can't see what the difference is between what you made and what I was trying, but whatever... it works now. Thanks so much!
your welcome :) glad it
your welcome :) glad it helped
Thanks
Not really sure either it's the place to post, put it really helped me sort the trick with glossary configuration in arguments
Thx
Fredrik Lahode
Développeur et Formateur web indépendant
Glad it worked :)
Glad it worked :)
Need little customization
Thanks for the great help. Can you help me in editing the view so that only the top level terms of any stated vocabulary is included in glossary. Example: Suppose Vocabualry= Location, Parent terms: Asia, Africa, America n Europe. So what I need is that glossary should display only A|E in this case.
Quick response will be appreciated. Thanks in advance.
Meeta
Does not work for me...
Drupal 7.21
Views 7.x-3.5
The things I've changed:
Title: None
Grid Settings: Number of columns * =1
Filter criteria: Taxonomy term: Vocabulary (= Translator)
Page settings: Path: /translators-alphabet
If I go to the page I see the letters and all the names, if I click one of the letters it does nothing, even though the link shows that is going to /translators-alphabet/t for instance, it does not go, so if I type it manually it shows a blank page.
If I go to the attacment preview and I click the letter from there it also sends me to a blank page.
At some points the system shows me this message:
Notice: Undefined property: views_many_to_one_helper::$placeholders in views_many_to_one_helper->add_filter() (line 1032 of .../sites/all/modules/views/includes/handlers.inc).I would appreciate a lot if you could help me on this.
Thanks
@ch
Some changes make it work
I change ajax to no in the page view and that did it, so if somebody is interested in this kind of view I paste mine here, I hope it helps.
@ch
Thanks!
Just like to say a big thanks! Saved me a few hours to say the least ;)
Update: Sorry, I get the following error on the resulting page:
Warning: Creating default object from empty value in views_many_to_one_helper->summary_join() (line 865 of ...\sites\all\modules\views\includes\handlers.inc).Thanks
For sharing glossary view.
It works without any issue.