I created a view to display my content type "subject" I searched it as a forum (I do not use the forum module).
My problem is when I add relationships to my view to calculate the number of topics and comments. The view only displays forums containing comments.
How to view all forums (even those that have no comments) ?
Here is an export of my view :
$view = new view();
$view->name = 'forum';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'taxonomy_term_data';
$view->human_name = 'Forum';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Liste des forums';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'plus';
$handler->display->display_options['group_by'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'time';
$handler->display->display_options['cache']['results_lifespan'] = '3600';
$handler->display->display_options['cache']['results_lifespan_custom'] = '0';
$handler->display->display_options['cache']['output_lifespan'] = '3600';
$handler->display->display_options['cache']['output_lifespan_custom'] = '0';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Appliquer';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Réinitialiser';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Trier par';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'views_bootstrap_table_plugin_style';
$handler->display->display_options['style_options']['columns'] = array(
'name' => 'name',
'description' => 'description',
'nothing' => 'nothing',
'title' => 'title',
'comment_count' => 'comment_count',
'expression' => 'expression',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'name' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'description' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'nothing' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'comment_count' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'expression' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
$handler->display->display_options['style_options']['bootstrap_styles'] = array(
'striped' => 'striped',
'bordered' => 'bordered',
'hover' => 'hover',
'condensed' => 0,
);
$handler->display->display_options['style_options']['responsive'] = 0;
/* Relation: Terme de taxonomie : Contenu utilisant Forum */
$handler->display->display_options['relationships']['reverse_field_sujet_forum_node_1']['id'] = 'reverse_field_sujet_forum_node_1';
$handler->display->display_options['relationships']['reverse_field_sujet_forum_node_1']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['reverse_field_sujet_forum_node_1']['field'] = 'reverse_field_sujet_forum_node';
/* Relation: Commentaire : Dernier commentaire */
$handler->display->display_options['relationships']['cid']['id'] = 'cid';
$handler->display->display_options['relationships']['cid']['table'] = 'node_comment_statistics';
$handler->display->display_options['relationships']['cid']['field'] = 'cid';
$handler->display->display_options['relationships']['cid']['relationship'] = 'reverse_field_sujet_forum_node_1';
/* Relation: Commentaire : Auteur */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'comment';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['relationship'] = 'cid';
/* Relation: Commentaire : Contenu */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['relationship'] = 'cid';
/* Champ: Terme de taxonomie : Nom */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE;
/* Champ: Terme de taxonomie : Description du terme */
$handler->display->display_options['fields']['description']['id'] = 'description';
$handler->display->display_options['fields']['description']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['description']['field'] = 'description';
$handler->display->display_options['fields']['description']['label'] = '';
$handler->display->display_options['fields']['description']['exclude'] = TRUE;
$handler->display->display_options['fields']['description']['element_label_colon'] = FALSE;
/* Champ: Global : Texte personnalisé */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = 'Forums';
$handler->display->display_options['fields']['nothing']['alter']['text'] = '<h2 class="forum-title">[name]</h2>
[description]';
/* Champ: COUNT(DISTINCT Contenu : Titre) */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['relationship'] = 'reverse_field_sujet_forum_node_1';
$handler->display->display_options['fields']['title']['group_type'] = 'count_distinct';
$handler->display->display_options['fields']['title']['label'] = 'Sujets';
/* Champ: Contenu : Nombre de commentaires */
$handler->display->display_options['fields']['comment_count']['id'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics';
$handler->display->display_options['fields']['comment_count']['field'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['relationship'] = 'nid';
$handler->display->display_options['fields']['comment_count']['label'] = '';
$handler->display->display_options['fields']['comment_count']['exclude'] = TRUE;
$handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE;
/* Champ: Global : Expression mathématique */
$handler->display->display_options['fields']['expression']['id'] = 'expression';
$handler->display->display_options['fields']['expression']['table'] = 'views';
$handler->display->display_options['fields']['expression']['field'] = 'expression';
$handler->display->display_options['fields']['expression']['label'] = 'Contributions';
$handler->display->display_options['fields']['expression']['precision'] = '0';
$handler->display->display_options['fields']['expression']['expression'] = '[title]+[comment_count]';
/* Champ: Suivi - Utilisateur : Date de mise à jour */
$handler->display->display_options['fields']['changed']['id'] = 'changed';
$handler->display->display_options['fields']['changed']['table'] = 'tracker_user';
$handler->display->display_options['fields']['changed']['field'] = 'changed';
$handler->display->display_options['fields']['changed']['relationship'] = 'reverse_field_sujet_forum_node_1';
$handler->display->display_options['fields']['changed']['label'] = '';
$handler->display->display_options['fields']['changed']['exclude'] = TRUE;
$handler->display->display_options['fields']['changed']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['changed']['date_format'] = 'short';
$handler->display->display_options['fields']['changed']['second_date_format'] = 'long';
$handler->display->display_options['fields']['changed']['format_date_sql'] = 0;
/* Champ: Global : Texte personnalisé */
$handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
$handler->display->display_options['fields']['nothing_1']['table'] = 'views';
$handler->display->display_options['fields']['nothing_1']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing_1']['label'] = 'Dernière contribution';
$handler->display->display_options['fields']['nothing_1']['alter']['text'] = '[changed]';
/* Critère de filtrage: Vocabulaire de taxonomie : Nom système */
$handler->display->display_options['filters']['machine_name']['id'] = 'machine_name';
$handler->display->display_options['filters']['machine_name']['table'] = 'taxonomy_vocabulary';
$handler->display->display_options['filters']['machine_name']['field'] = 'machine_name';
$handler->display->display_options['filters']['machine_name']['value'] = array(
'forum' => 'forum',
);
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'forum';
$translatables['forum'] = array(
t('Master'),
t('Liste des forums'),
t('plus'),
t('Appliquer'),
t('Réinitialiser'),
t('Trier par'),
t('Asc'),
t('Desc'),
t('field_sujet_forum'),
t('Dernier commentaire'),
t('auteur'),
t('Contenu'),
t('Forums'),
t('<h2 class="forum-title">[name]</h2>
[description]'),
t('Sujets'),
t('.'),
t(','),
t('Contributions'),
t('Dernière contribution'),
t('[changed]'),
t('Page'),
);
Here is a screenshot of my view (In Relationship, the "Require this relationship" boxes are not checked) :
Here is the result :
Here is the content of the forum "Cuisine" :
Here are the full forums that should be posted (sorry I changed the titles). As you can see, it lacks in the previous view the forum without comments.