-1

I want to build a statistical of ours projects inside my structure. I have a taxonomy term status with the terms ongoing, achieved, not rated and pending.

An my content type have a relationship to this term. Now I want to show something like this using view and aggregation.

  • ongoing (2)
  • achieved (2)
  • Not rated (12)
  • pending (0)

But the issue is the last term "pending" is not visible because it have 0 attached node.

But I want to show it with the 0. Please how can I solved this issue.

This is my interface of view. The term with 0 node disappear. enter image description here

In attached my exporting view. $view = new view(); $view->name = 'clone_view_for_issue'; $view->description = ''; $view->tag = 'default'; $view->base_table = 'taxonomy_term_data'; $view->human_name = 'CLONE VIEW FOR ISSUE'; $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'] = 'VIEW DE TEST TAXO'; $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'perm'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; $handler->display->display_options['pager']['type'] = 'some'; $handler->display->display_options['pager']['options']['items_per_page'] = '10'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'fields'; / Field: Taxonomy term: Name / $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']['alter']['word_boundary'] = FALSE; $handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE; $handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE; / Filter criterion: Taxonomy vocabulary: Machine name / $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( 'thematique' => 'thematique', ); / Display: Block test 1 / $handler = $view->new_display('block', 'Block test 1', 'block_1'); $handler->display->display_options['defaults']['title'] = FALSE; $handler->display->display_options['title'] = 'Nombre total d\'engagement'; $handler->display->display_options['defaults']['use_ajax'] = FALSE; $handler->display->display_options['use_ajax'] = TRUE; $handler->display->display_options['defaults']['group_by'] = FALSE; $handler->display->display_options['group_by'] = TRUE; $handler->display->display_options['defaults']['query'] = FALSE; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['defaults']['pager'] = FALSE; $handler->display->display_options['pager']['type'] = 'none'; $handler->display->display_options['pager']['options']['offset'] = '0'; $handler->display->display_options['defaults']['style_plugin'] = FALSE; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['defaults']['style_options'] = FALSE; $handler->display->display_options['defaults']['row_plugin'] = FALSE; $handler->display->display_options['row_plugin'] = 'fields'; $handler->display->display_options['defaults']['row_options'] = FALSE; $handler->display->display_options['defaults']['relationships'] = FALSE; / Relationship: Taxonomy term: Content using Note engagement / $handler->display->display_options['relationships']['reverse_field_note_engagement_node']['id'] = 'reverse_field_note_engagement_node'; $handler->display->display_options['relationships']['reverse_field_note_engagement_node']['table'] = 'taxonomy_term_data'; $handler->display->display_options['relationships']['reverse_field_note_engagement_node']['field'] = 'reverse_field_note_engagement_node'; $handler->display->display_options['defaults']['fields'] = FALSE; / Field: Content: Nid / $handler->display->display_options['fields']['nid']['id'] = 'nid'; $handler->display->display_options['fields']['nid']['table'] = 'node'; $handler->display->display_options['fields']['nid']['field'] = 'nid'; $handler->display->display_options['fields']['nid']['relationship'] = 'reverse_field_note_engagement_node'; $handler->display->display_options['fields']['nid']['group_type'] = 'count'; $handler->display->display_options['fields']['nid']['label'] = ''; $handler->display->display_options['fields']['nid']['exclude'] = TRUE; $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE; $handler->display->display_options['fields']['nid']['empty'] = '0'; $handler->display->display_options['fields']['nid']['hide_alter_empty'] = FALSE; / Field: Taxonomy term: Name / $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']['alter']['alter_text'] = TRUE; $handler->display->display_options['fields']['name']['alter']['text'] = ' [name] ([nid])


'; $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']['empty'] = '[view] [name] (0)
'; $handler->display->display_options['fields']['name']['hide_alter_empty'] = FALSE; $handler->display->display_options['defaults']['arguments'] = FALSE; /
Contextual filter: Content: Has taxonomy term ID / $handler->display->display_options['arguments']['tid']['id'] = 'tid'; $handler->display->display_options['arguments']['tid']['table'] = 'taxonomy_index'; $handler->display->display_options['arguments']['tid']['field'] = 'tid'; $handler->display->display_options['arguments']['tid']['relationship'] = 'reverse_field_note_engagement_node'; $handler->display->display_options['arguments']['tid']['default_action'] = 'empty'; $handler->display->display_options['arguments']['tid']['default_argument_type'] = 'fixed'; $handler->display->display_options['arguments']['tid']['summary']['number_of_records'] = '0'; $handler->display->display_options['arguments']['tid']['summary']['format'] = 'default_summary'; $handler->display->display_options['arguments']['tid']['summary_options']['items_per_page'] = '25'; $handler->display->display_options['arguments']['tid']['specify_validation'] = TRUE; $handler->display->display_options['arguments']['tid']['break_phrase'] = TRUE; $handler->display->display_options['defaults']['filter_groups'] = FALSE; $handler->display->display_options['defaults']['filters'] = FALSE; / Filter criterion: Taxonomy vocabulary: Machine name / $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( 'min' => '', 'max' => '', 'value' => '', 'status' => 'status', ); / Filter criterion: Content: Type */ $handler->display->display_options['filters']['type']['id'] = 'type'; $handler->display->display_options['filters']['type']['table'] = 'node'; $handler->display->display_options['filters']['type']['field'] = 'type'; $handler->display->display_options['filters']['type']['relationship'] = 'reverse_field_note_engagement_node'; $handler->display->display_options['filters']['type']['value'] = array( 'engagement' => 'engagement', );

0

I am assuming that you are using a "Content" in views, since the taxonomy term is being removed when there are no nodes referenced. I suggest to use the "Taxonomy Terms" instead of the "Content" to display all the terms and just use a relationship to get the nodes attached.

Please see below:

  • Create a taxonomy term type views.
  • Filter the view to "Status". (Which is your current vocabulary)

enter image description here

  • Add to relationship your taxonomy field "Content using Status".

enter image description here

  • Turn on aggregation
  • Add "NID" field to count nodes associated with the term.

enter image description here

  • Save
  • I did exactly your soltion but the status with 0 node disappear. See my interface's capture – Z.Lass Jul 25 '17 at 13:32
  • Could you please export your view and attach it here, so I could check it. – Madelyn Cruz Jul 25 '17 at 13:41
  • I edited the post and you can see the code of the view – Z.Lass Jul 25 '17 at 14:02
0

Here is a simple method available for the same :

$tid = 'Enter tid number say 5';
$nids = taxonomy_select_nodes($tid, FALSE);
// count node here
$count = count($nids);
// you can load node content here
$nodes = node_load_multiple($nids);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.