Grouping content by taxonomy, multiple taxonomies by node Note: The solution should not change the main Views properties, mainly that it is a View of content nodes.

I have a content type (books) which are under a taxonomy (Category). I have created a View to show the titles. By using "Grouping field" with the category (see picture #1), I can get the title of the category and order by that.

However, when I have books which are classified under several Categories (in this example, the book about Chess is under Sports and Science), I get a mixture of taxonomies in the Grouping field displayed, and the book does not appear in the other categories. I would like it to appear under Sports and under Sciende, and get rid of this "third" combined taxonomy "Science, Sports". (see picture #2).

Image 1



Image 2
You have many solutions available.

Solution 1:

Enable "Use aggregation" option with the default settings, it should be enough.

Solution 2:

You can create a view of terms and add a "Relationships" with "Taxonomy term: Content using Category". As fields you have to add the content fields (with the new relation) and the term name (used for the grouping).

This is an example of the view assuming the content type is "article", the category field is called "field_category" and the vocabulary is "category":

$view = new view();
$view-&gt;name = 'nestedexample';
$view-&gt;description = '';
$view-&gt;tag = 'default';
$view-&gt;base_table = 'taxonomy_term_data';
$view-&gt;human_name = 'nestedexample';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view-&gt;new_display('default', 'Master', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'nestedexample';
$handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'perm';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'default';
$handler-&gt;display-&gt;display_options['style_options']['grouping'] = array(
  0 =&gt; array(
    'field' =&gt; 'name',
    'rendered' =&gt; 1,
    'rendered_strip' =&gt; 0,
  ),
);
$handler-&gt;display-&gt;display_options['row_plugin'] = 'fields';
/* Relationship: Taxonomy term: Content using Category */
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_category_node']['id'] = 'reverse_field_category_node';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_category_node']['table'] = 'taxonomy_term_data';
$handler-&gt;display-&gt;display_options['relationships']['reverse_field_category_node']['field'] = 'reverse_field_category_node';
/* Field: Taxonomy term: Name */
$handler-&gt;display-&gt;display_options['fields']['name']['id'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler-&gt;display-&gt;display_options['fields']['name']['field'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['label'] = '';
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler-&gt;display-&gt;display_options['fields']['name']['link_to_taxonomy'] = TRUE;
/* Field: Content: Title */
$handler-&gt;display-&gt;display_options['fields']['title']['id'] = 'title';
$handler-&gt;display-&gt;display_options['fields']['title']['table'] = 'node';
$handler-&gt;display-&gt;display_options['fields']['title']['field'] = 'title';
$handler-&gt;display-&gt;display_options['fields']['title']['relationship'] = 'reverse_field_category_node';
/* Field: Taxonomy term: Name */
$handler-&gt;display-&gt;display_options['fields']['name_1']['id'] = 'name_1';
$handler-&gt;display-&gt;display_options['fields']['name_1']['table'] = 'taxonomy_term_data';
$handler-&gt;display-&gt;display_options['fields']['name_1']['field'] = 'name';
/* Sort criterion: Content: Title */
$handler-&gt;display-&gt;display_options['sorts']['title']['id'] = 'title';
$handler-&gt;display-&gt;display_options['sorts']['title']['table'] = 'node';
$handler-&gt;display-&gt;display_options['sorts']['title']['field'] = 'title';
$handler-&gt;display-&gt;display_options['sorts']['title']['relationship'] = 'reverse_field_category_node';
/* Sort criterion: Taxonomy term: Name */
$handler-&gt;display-&gt;display_options['sorts']['name']['id'] = 'name';
$handler-&gt;display-&gt;display_options['sorts']['name']['table'] = 'taxonomy_term_data';
$handler-&gt;display-&gt;display_options['sorts']['name']['field'] = 'name';
/* Filter criterion: Taxonomy vocabulary: Machine name */
$handler-&gt;display-&gt;display_options['filters']['machine_name']['id'] = 'machine_name';
$handler-&gt;display-&gt;display_options['filters']['machine_name']['table'] = 'taxonomy_vocabulary';
$handler-&gt;display-&gt;display_options['filters']['machine_name']['field'] = 'machine_name';
$handler-&gt;display-&gt;display_options['filters']['machine_name']['value'] = array(
  'category' =&gt; 'category',
);

/* Display: Page */
$handler = $view-&gt;new_display('page', 'Page', 'page');
$handler-&gt;display-&gt;display_options['path'] = 'nestedexample';


Solution 3:
Another solution is adding a relationshipt with the taxonomy terms "Content: Taxonomy terms on node" and use the taxonomy term from the relationship as group by field.
I hope this will help you.