I've been scouring the issues to try to find a solution and can't seem to pinpoint the right one.
I'm trying to create a list of all Terms that have nodes attached to them.
For example:
Vocabulary: Genres
Terms: Rock, Pop, Rap
Rock - Green Day Album
Rock - Aerosmith Album
Pop - Lady Gaga
Rap - Fabolous
Rap - Eminem
I would want my view to display:
Pop
Rap
Rock
If possible, even:
Pop
Rap (2)
Rock (2)
I applied following:
Basic Settings: default (unformatted, etc)
Fields:
- Taxonomy: All Terms, Limit Terms by Vocabulary: "Genres"
Filters:
- Taxonomy: Vocabulary: Genres
Sort:
- Taxonomy: Terms "asc"
The result is:
Pop
Rap
Rap
Rock
Rock
I tried distinct (no go cause it's distinct on the nodes not terms), etc but nothing so far. Any guidance will be much appreciated! (Sorry if this is a duplicate!)
Comments
Comment #1
sabbathchild commentedTrying to do something similar and having the same issue. There has to be a way around this.
Comment #2
drupal3008 commentedI think I've got it figured out:
Key is in the "Arguments" section -
- Add an argument for "Taxonomy - Term"
- Title: %1 Gallery
- Action to take: Summary, sorted Ascending
- Wildcard: All
- Wildcard Title: All
- Basic Validation
- Hide view / Page...
- Case: Capitalize each word (This is my preference)
- Case in path: Lower case
- Transform spaces to dashes (checked)
- On next option after you add field, select: List
Comment #3
ali_b commentedhm, i have something similar. Various events with dates. Want do display all events "this weekend". Using Date module with ckk and views, I can do it - but: if there is an event, a movie playing on Saturday and also on Sunday, it is displayed twice.
$view = new view;
$view->name = 'all_movies';
$view->description = 'List of movies.';
$view->tag = '';
$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(
'field_datum_value' => array(
'label' => 'Dátum',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'group' => 0,
),
'repeat' => array(
'show_repeat_rule' => '',
),
'fromto' => array(
'fromto' => 'both',
),
'exclude' => 0,
'id' => 'field_datum_value',
'table' => 'node_data_field_datum',
'field' => 'field_datum_value',
'relationship' => 'none',
),
'title' => array(
'label' => 'Názov',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'field_datum_value' => array(
'order' => 'ASC',
'delta' => '0',
'id' => 'field_datum_value',
'table' => 'node_data_field_datum',
'field' => 'field_datum_value',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'date_argument' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Všetky',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'date_fields' => array(
'node_data_field_datum.field_datum_value' => 'node_data_field_datum.field_datum_value',
),
'year_range' => '-3:+3',
'date_method' => 'OR',
'granularity' => 'day',
'id' => 'date_argument',
'table' => 'node',
'field' => 'date_argument',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'webform' => 0,
'film' => 0,
'kino' => 0,
'koncert' => 0,
'page' => 0,
'story' => 0,
'vystava' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'2' => 0,
'1' => 0,
'4' => 0,
'3' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'film' => 'film',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'language' => array(
'operator' => 'in',
'value' => array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'language',
'table' => 'node',
'field' => 'language',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 4);
$handler->override_option('use_pager', '1');
$handler->override_option('distinct', 1);
$handler->override_option('style_options', NULL);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'relationship' => 'none',
'build_mode' => 'teaser',
'links' => 0,
'comments' => 0,
));
$handler = $view->new_display('block', 'Dnes a zajtra', 'block_1');
$handler->override_option('arguments', array(
'date_argument' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Všetky',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'date',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'date_fields' => array(
'node_data_field_datum.field_datum_value' => 'node_data_field_datum.field_datum_value',
),
'year_range' => '-3:+3',
'date_method' => 'OR',
'granularity' => 'day',
'id' => 'date_argument',
'table' => 'node',
'field' => 'date_argument',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'webform' => 0,
'film' => 0,
'kino' => 0,
'koncert' => 0,
'page' => 0,
'story' => 0,
'vystava' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
'override' => array(
'button' => 'Use default',
),
),
));
$handler->override_option('style_options', array());
$handler->override_option('row_options', array(
'relationship' => 'none',
'build_mode' => 'full',
'links' => 0,
'comments' => 0,
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('block', 'Tento mesiac', 'block_2');
$handler->override_option('arguments', array(
'date_argument' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Všetky',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'date',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'date_fields' => array(
'node_data_field_datum.field_datum_value' => 'node_data_field_datum.field_datum_value',
),
'year_range' => '-3:+3',
'date_method' => 'OR',
'granularity' => 'month',
'id' => 'date_argument',
'table' => 'node',
'field' => 'date_argument',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'webform' => 0,
'film' => 0,
'kino' => 0,
'koncert' => 0,
'page' => 0,
'story' => 0,
'vystava' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
'override' => array(
'button' => 'Use default',
),
),
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('block', 'Tento týždeň', 'block_3');
$handler->override_option('arguments', array(
'date_argument' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Všetky',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'date',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'date_fields' => array(
'node_data_field_datum.field_datum_value' => 'node_data_field_datum.field_datum_value',
),
'year_range' => '-3:+3',
'date_method' => 'OR',
'granularity' => 'week',
'id' => 'date_argument',
'table' => 'node',
'field' => 'date_argument',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'webform' => 0,
'film' => 0,
'kino' => 0,
'koncert' => 0,
'page' => 0,
'story' => 0,
'vystava' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
'override' => array(
'button' => 'Use default',
),
),
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('block', 'Tento víkend', 'block_4');
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'film' => 'film',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'language' => array(
'operator' => 'in',
'value' => array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'language',
'table' => 'node',
'field' => 'language',
'relationship' => 'none',
),
'date_filter' => array(
'operator' => 'between',
'value' => array(
'value' => NULL,
'min' => NULL,
'max' => NULL,
'default_date' => 'next Saturday',
'default_to_date' => 'next Sunday',
),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'date_filter_op',
'identifier' => 'date_filter',
'label' => 'Dátum: Date (node)',
'optional' => 0,
'remember' => 0,
),
'date_fields' => array(
'node_data_field_datum.field_datum_value' => 'node_data_field_datum.field_datum_value',
),
'date_method' => 'OR',
'granularity' => 'day',
'form_type' => 'date_select',
'default_date' => 'next Saturday',
'default_to_date' => 'next Sunday',
'year_range' => '-3:+3',
'id' => 'date_filter',
'table' => 'node',
'field' => 'date_filter',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
));
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
Comment #4
Alun commentedThe post above is far too large.
This issue is something i want to solve too, it has already been raised.
See http://drupal.org/node/240872
There is a possible hack/fix which is mentioned on the post above. I am looking into perhaps getting a custom module to sort this out - I will post back if I have any success.
Comment #5
Alun commentedI solved the problem myself after hacking around in query.inc
In the current views version, (2.7, drupal 6) on line 984, I replaced the line
$groupby = "GROUP BY " . implode(', ', array_unique(array_merge($this->groupby, $non_aggregates))) . "\n";with
$groupby = "GROUP BY " . implode(', ', array_unique($this->groupby)) . "\n";Which allowed me to create a custom module that used hook_views_query_alter to add my group by clause without any problems! I think it goes against some things, but it works for my website, which is what I was looking for!
Comment #6
clane commentedI too have the same issue as detailed in this topic. However, I won't hack the drupal core to accomplish this feat.
My situation is identical. Case Studies by Industry. I want to show 5 random case studies in a right block with their respective industry category names above them. Unfortunately, I keep coming up with Education 2x in the block no matter what settings I try in Views 2. I have tried both taxonomy and a CCK field, all the settings mentioned above, but exclusing the file modification to query.inc.
Aren't there any settings in views or php code that can be used to resolve the issue in this topic?
Thanks for any help!
Colette
Comment #7
Alun commentedColette, have you tried modifying the query to see if that works? If it does, you might have to go with that choice to get what you want.
I filed an issue on Views a while ago, noting the problem I had, but the maintainer said it cannot be fixed.
http://drupal.org/node/624646
Comment #8
clane commentedalzum,
Thanks for the insight and keeping this on the radar. This should be a feature upgrade for Views 3. I'll give the query modification a try.
Take care,
Colette
Comment #9
deo_vinay commentedThanks makingbigthings,
I am a newbie in drupal trying to do something basic.I achieved the task using the solution provided by u.Thanks a lot for ur step by step procedure.Thnks again.
Tk care,
Vinay
Comment #10
jasonsbytes commentedThe argument option works.
Comment #11
drupal3008 commented#2 works.
Comment #12
RedTop commented#2 works, but is very basic and may not provide enough functionality for everyone (doesn't for me).
I'm trying to get a list of distinct terms of all nodes of a certain content type, grouped by vocabulary. The terms link to their (customized) term pages, for example allowing a listing of all "articles" (content type) about "disability" (term). I use terms from three vocabularies, which I sort using a hidden 'vocabulary name' field.
Right now the list obviously contains duplicates as the view simply lists the terms of every node that passes the filtercriteria (being content type=article and published=yes). I had figured out the same approach as in #2, but that just produces a list of terms without the possibility to sort by vocabulary. It gets me close, but just not close enough...
I found this:
http://himerus.com/blog/himerus/fixing-duplicate-taxonomy-terms-node-vie...
That seems to do what I am looking for but I haven't been able to get it to work (see my comment on that page).Got it to work thanks to some input by the author. I needed to print the output of $view to find out the correct name pattern.
Comment #13
RedTop commentedSolution added to Drupal's documentation
http://drupal.org/node/770782
Comment #15
rakesh.gectcrGreetings
The argument option is working