I have a Views table that contains a grouping field. It is the 2nd field in the view.

When I open the view in a browser, it shows like this:

AAA

[field A name]  [field B name]
--------------- --------------
111             AAA

AAA

[field A name]  [field B name]
--------------- --------------
222             AAA

BBB

[field A name]  [field B name]
--------------- --------------
333             BBB

CCC

[field A name]  [field B name]
--------------- --------------
444             CCC

CCC

[field A name]  [field B name]
--------------- --------------
555             CCC

So instead of having grouping, I instead get something like a new title over one table for each row in the original table.

Here's the entire view:

<?php
$view
= new view;
$view->name = 'quotes';
$view->description = 'Quotes by Category';
$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(
 
'title' => array(
   
'label' => 'Title',
   
'link_to_node' => 1,
   
'exclude' => 0,
   
'id' => 'title',
   
'table' => 'node',
   
'field' => 'title',
   
'relationship' => 'none',
  ),
 
'field_article_nid' => array(
   
'label' => 'Article',
   
'link_to_node' => 1,
   
'label_type' => 'widget',
   
'format' => 'default',
   
'multiple' => array(
     
'group' => TRUE,
     
'multiple_number' => '',
     
'multiple_from' => '',
     
'multiple_reversed' => FALSE,
    ),
   
'exclude' => 0,
   
'id' => 'field_article_nid',
   
'table' => 'node_data_field_article',
   
'field' => 'field_article_nid',
   
'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
 
'tid' => array(
   
'default_action' => 'ignore',
   
'style_plugin' => 'default_summary',
   
'style_options' => array(),
   
'wildcard' => 'all',
   
'wildcard_substitution' => 'All',
   
'title' => '',
   
'default_argument_type' => 'fixed',
   
'default_argument' => '',
   
'validate_type' => 'none',
   
'validate_fail' => 'not found',
   
'break_phrase' => 0,
   
'add_table' => 0,
   
'require_value' => 0,
   
'reduce_duplicates' => 0,
   
'set_breadcrumb' => 0,
   
'id' => 'tid',
   
'table' => 'term_node',
   
'field' => 'tid',
   
'relationship' => 'none',
   
'default_options_div_prefix' => '',
   
'default_argument_user' => 0,
   
'default_argument_fixed' => '',
   
'default_argument_php' => '',
   
'validate_argument_node_type' => array(
     
'poll' => 0,
     
'forum' => 0,
     
'article' => 0,
     
'book' => 0,
     
'move_over_law' => 0,
     
'page' => 0,
     
'publication' => 0,
     
'quote' => 0,
     
'story' => 0,
    ),
   
'validate_argument_node_access' => 0,
   
'validate_argument_nid_type' => 'nid',
   
'validate_argument_vocabulary' => array(
     
'2' => 0,
     
'1' => 0,
    ),
   
'validate_argument_type' => 'tid',
   
'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
 
'type' => array(
   
'operator' => 'in',
   
'value' => array(
     
'quote' => 'quote',
    ),
   
'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',
  ),
));
$handler->override_option('access', array(
 
'type' => 'none',
));
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
 
'grouping' => 'field_article_nid',
 
'override' => 1,
 
'sticky' => 1,
 
'order' => 'asc',
 
'columns' => array(
   
'title' => 'title',
   
'field_article_nid' => 'field_article_nid',
  ),
 
'info' => array(
   
'title' => array(
     
'sortable' => 0,
     
'separator' => '',
    ),
   
'field_article_nid' => array(
     
'separator' => '',
    ),
  ),
 
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'quotes');
$handler->override_option('menu', array(
 
'type' => 'none',
 
'title' => '',
 
'weight' => 0,
 
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
 
'type' => 'none',
 
'title' => '',
 
'weight' => 0,
));
?>

Here's the query:

SELECT node.nid AS nid,
   node.title AS node_title,
   node_data_field_article.field_article_nid AS node_data_field_article_field_article_nid,
   node_data_field_article.nid AS node_data_field_article_nid,
   node.type AS node_type
FROM speed_node node
LEFT JOIN speed_content_type_quote node_data_field_article ON node.vid = node_data_field_article.vid
WHERE (node.type in ('quote')) AND (node.status <> 0)

Comments

jrefano’s picture

I have the identical issue, I'm getting two rows for the same node when it should just list the node once and display all the fields. Seems to have something to do with multiple values for a field.

merlinofchaos’s picture

Aren, this kind of thing can happen when 'link to node' is used, because the link may be subtly different. Try turning off link to node and see if the effect remains.

jrefano’s picture

I just tried turning off "link to node" on my view with the same issue, same results.

Removing my multiple value allowed CCK field from the fields "fixes" the issue.

jrefano’s picture

deleted: duplicate submit, sorry

Aren Cambre’s picture

Ok, turning off "link to node" on field_article_nid is a partial solution, but I still have two problems:

1: The second field is still a link even though "link to node" is disabled. In this case, it's OK. The field type is a nodereference. But I can envision scenarios where I will not wish for the fieldreference to be a link to the node. This may need to be a separate issue?

2: The resulting view still has the grouping field's value showing up multiple times. Even when only one node is in the group, the field's value shows up two times (BBB in the case below).

AAA

[field A name]  [field B name]
--------------- --------------
111             AAA
222             AAA

BBB

[field A name]  [field B name]
--------------- --------------
333             BBB

CCC

[field A name]  [field B name]
--------------- --------------
444             CCC
555             CCC

Here's thew new view code:

<?php
$view
= new view;
$view->name = 'quotes_grouping';
$view->description = 'Quotes by Category';
$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(
 
'title' => array(
   
'label' => 'Title',
   
'link_to_node' => 1,
   
'exclude' => 0,
   
'id' => 'title',
   
'table' => 'node',
   
'field' => 'title',
   
'relationship' => 'none',
  ),
 
'field_article_nid' => array(
   
'label' => 'Article',
   
'link_to_node' => 0,
   
'label_type' => 'widget',
   
'format' => 'default',
   
'multiple' => array(
     
'group' => TRUE,
     
'multiple_number' => '',
     
'multiple_from' => '',
     
'multiple_reversed' => FALSE,
    ),
   
'exclude' => 0,
   
'id' => 'field_article_nid',
   
'table' => 'node_data_field_article',
   
'field' => 'field_article_nid',
   
'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
 
'tid' => array(
   
'default_action' => 'ignore',
   
'style_plugin' => 'default_summary',
   
'style_options' => array(),
   
'wildcard' => 'all',
   
'wildcard_substitution' => 'All',
   
'title' => '',
   
'default_argument_type' => 'fixed',
   
'default_argument' => '',
   
'validate_type' => 'none',
   
'validate_fail' => 'not found',
   
'break_phrase' => 0,
   
'add_table' => 0,
   
'require_value' => 0,
   
'reduce_duplicates' => 0,
   
'set_breadcrumb' => 0,
   
'id' => 'tid',
   
'table' => 'term_node',
   
'field' => 'tid',
   
'relationship' => 'none',
   
'default_options_div_prefix' => '',
   
'default_argument_user' => 0,
   
'default_argument_fixed' => '',
   
'default_argument_php' => '',
   
'validate_argument_node_type' => array(
     
'poll' => 0,
     
'forum' => 0,
     
'article' => 0,
     
'book' => 0,
     
'move_over_law' => 0,
     
'page' => 0,
     
'publication' => 0,
     
'quote' => 0,
     
'story' => 0,
    ),
   
'validate_argument_node_access' => 0,
   
'validate_argument_nid_type' => 'nid',
   
'validate_argument_vocabulary' => array(
     
'2' => 0,
     
'1' => 0,
    ),
   
'validate_argument_type' => 'tid',
   
'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
 
'type' => array(
   
'operator' => 'in',
   
'value' => array(
     
'quote' => 'quote',
    ),
   
'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',
  ),
));
$handler->override_option('access', array(
 
'type' => 'none',
));
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
 
'grouping' => 'field_article_nid',
 
'override' => 1,
 
'sticky' => 0,
 
'order' => 'asc',
 
'columns' => array(
   
'title' => 'title',
   
'field_article_nid' => 'field_article_nid',
  ),
 
'info' => array(
   
'title' => array(
     
'sortable' => 0,
     
'separator' => '',
    ),
   
'field_article_nid' => array(
     
'separator' => '',
    ),
  ),
 
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'quotes');
$handler->override_option('menu', array(
 
'type' => 'none',
 
'title' => '',
 
'weight' => 0,
 
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
 
'type' => 'none',
 
'title' => '',
 
'weight' => 0,
));
?>
merlinofchaos’s picture

1) nodereference is its own field and its own thing.
2) Um? What you have as an example displayed looks roughly correct, and doesn't seem to match what you said. I'm confused here.

Aren Cambre’s picture

Title:Grouping field not working correctly» Grouping field problem when "link to node" enabled

Oh, I see, I need to exclude the second field from display. I've revised title to be more precise.

Aren Cambre’s picture

Version:6.x-2.2» 6.x-2.6

Whoops, just opened a new issue for the same problem. Marked as duplicate: #497618: Grouping field displays with each node with unformatted style.

Aren Cambre’s picture

Looks like #267771: Link to node in formatters instead of Views? may help? At least it could allow removal of "link to node" option, eliminating need to fix this issue?

Really, there's no need to select "link to node" with a nodereference because the Format dropdown includes an option that creates a link to the node.

merlinofchaos’s picture

Views has no control over what CCK provides on its fields.

Aren Cambre’s picture

Should this issue be marked as "Won't fix"? The problem will go away if #267771: Link to node in formatters instead of Views? is fixed.

merlinofchaos’s picture

Status:Active» Closed (won't fix)

Sounds reasonable to me.

Aren Cambre’s picture

Yikes. Looking for more signs of the apocalypse!