We have a view that should be filtered by the current user logged in via an automatic argument. With the argument in place, regardless of how many results we should get back, a single result is always returned. This result is filtered correctly via the argument.

If I take the argument away, we do get a full list of results, of course, not "filtered" by the argument we want.

Noodling into the node reference module in 6.x-2.4, I did a dump of $node->result on line 852 and that result has the correct number of nodes filtered correctly by the argument. Once this is sent to $view->execute_display, however, if only returns one.

I am not sure if this is a Views issue because of the Views plug-in in question (content_references) or a node reference issue. It looks like the view does get the result I want, but the execute display function returned to the node reference module reduces the result set along the way.

Files: 

Comments

Peter Bex’s picture

Anyone have a solution for this problem? I'm also having this problem, and it's almost a year later!

However, I'm seeing this even with a view with no arguments (using views 3). The view shows all the nodes, but the node reference form element is only showing one entry.

Also, I think #336725: View fails to reference multiple nodes in CCK "nodereference field" may be a duplicate of this. (it's a bit hard to tell with all the distracting details)

916Designs’s picture

Ive been getting this intermittently also with latest CCK and Views as of 9-4-10. Using select list and passing argument to the view via url. After much fussing about:

Add nid field into your view and choose "Exclude from Display"

drupalisme’s picture

This issue come from Views module rather than CCK.
Read this: http://drupal.org/node/896874
Temporary solution: http://drupal.org/node/896874#comment-3387328

liquidcms’s picture

Version:6.x-2.4» 6.x-2.8
Category:support» bug

#2 doesn't work for me.

#3's temp solution i think is to use cck 3.x and views 2.8; this combo also doesn't fix this issue for me

changing this to a bug.. as it clearly is one.. :)

liquidcms’s picture

if i were to guess i would say the issue stems from how noderef gets its results. In my particular case i have a view relationship which then is used in a reverse relationship.

as can be seen in this screenshot: http://screencast.com/t/YWJmZGQxYjI the noderef field is listing the NID of the correct node that i am trying to list but it only lists 1 value when there are really 2. The interesting part of this though is that it also lists Title: Indoor Volleyball which is the title of the passed in arg. My view is only set to list the first part (the NID).

I think the reason there is only 1 value is that it is really returning the NID of the first "root" node not the related node. This can be seen in the HTML for the select:

<option value="8597"> Nid:  8724 - Title Indoor Volleyball</option>

where 8597 is the root node not the related node (which is 8724 as seen in the screenshot)

The preview of the View does of course return both rows.

clashar’s picture

subscribe

drupalisme’s picture

@liquidcms:
My working site uses Views 6.x-2.11 rather then 2.8. Can you test with Views 6.x-2.11 and confirm again?

clashar’s picture

drupal-id.com, I tried to change my Views 3.x.dev with Views 2.11, but with no success.
I have CCK.3.x.dev.

clashar’s picture

StatusFileSize
new31.29 KB

I tried to re-save view, I got this error:
user warning: Unknown column 'view_php' in 'field list' query: UPDATE views_view SET name = 'field_cv_location', description = 'select locations with node references from jobseeker profile', tag = '', view_php = '', base_table = 'node', is_cacheable = 0 WHERE vid = 22 in /home/bakpayev/public_html/paris.kz/emploi/sites/all/modules/views/includes/view.inc on line 1722.

screenshot is attached

Aldus’s picture

I have a problem which might be related to this issue (if it doesn't, let me know so I can open a new topic).

I have a node type "Artist" which can have references to 1 or more "Song" content.

In example:

Pink Floyd
-> "Another Brick in The Wall"
-> "Clocks"
-> "Money"
-> "Shine On You Crazy Diamond"

I then created a view with:

Filter: node type = "Artist"
Fields: node title
Fields: song_ref (node reference to song)

It returns:
Pink Floyd
Another Brick in The Wall

and nothing more.. It displays only the first reference.

So I tried to add a Node Relationship using song_ref, and to add another node title field related to it.
Nothing changed, only the first result is displayed.

I remember this working in the past years, however. So something must have happened with recent versions

djween’s picture

subscribe, I am having same issue.

Azol’s picture

Version:6.x-2.8» 6.x-2.9

subscribing, same issue here with 6.x-2.9
View returns correct set of values for user reference, but I only can see 1 entry.
Views 3.x-dev

Azol’s picture

Version:6.x-3.x-dev» 6.x-2.9

There are 2 problems as I see it:

1) if you have trouble with users: you should manually add uid field to your view (check Exclude from display) - for some reason it worked without one in earlier versions of Views, but it does not work anymore;

2) if you have trouble with nodes: add nid field instead;

3) User Reference only gets first 10 results from the view no matter how you set the pager in your view, because User Reference creates another view display with its own set of options. Same goes with Node Reference (I experienced similar issues with both)

See lines 728-730 of userreference.module:

// Limit result set size.
    $limit = isset($limit) ? $limit : 0;
    $view->display_handler->set_option('items_per_page', $limit);

Does anyone have an idea why it happens?

btown’s picture

Version:6.x-2.9» 6.x-3.x-dev

I'm having a similar issue: 10 results even though the view's 'use pager' is set to 'all items'. Results display correctly when I preview on the view's edit page, but when using a CCK node reference field, the results are limited the first 10.

btown’s picture

This thread addresses the issue of 10 results and talks about some workaround solutions http://drupal.org/node/998494

Azol’s picture

Version:6.x-2.9» 6.x-3.x-dev

To summarize:

1) You can use the workaround in #13 to make Node Reference (or User Reference) see more than 1 result
2) You can use the workaround in #2 of #998494: Node Reference field always displaying 10 results when using the Advanced View option. [views-6.x-3.x] to fix the "10 results max" issue as well

favosys’s picture

Hello I'm having the same problem and #13 doesn't help, I've tried adding the uid, the nid I've tried changing cck and views versions, I've tried changing the output with views templates and I can't see to find a solution.

I have a view where a user is related to his content profile. Then using node referral I get the nodes that reference that content profile. So the view shows me all these nodes correctly.

Then in cck I have a node reference field which I populate from the view but I only get the last node from the 6 or so nodes that appear on the view.

After checking the $data variable with a PHP customfield I can see that $data->nid is the node id of the content profile. For each row this is repeated. The referring nodes are $data->node_node_nid.

The select box in the cck field is like this:

<option value="32">LMN Care</option></select>

So basically it has the nid of the content profile (not good) and the last name of the actual nodes that I need.

How can I make those nodes be nid so they will show up in the cck field correctly?

Azol’s picture

In your view you are using relationships to refer those nodes, is that correct?
Then you should probably add the NID field (using corresponding relationship, of course) for the nodes that refer user's content profile.

favosys’s picture

StatusFileSize
new76.44 KB

Hi Azol, do you mean adding the nid to the fields because I did that and it doesn't work. Screenshot attached.

Azol’s picture

Consider upgrading to 6.x-3.x-dev version of Views. I tried to reproduce this issue once more using last dev version, but could not anymore. Anyone else?

10 nodes limit issue still stands though (#998494: Node Reference field always displaying 10 results when using the Advanced View option. [views-6.x-3.x]).

favosys’s picture

Ok now it got worst

Initially I had Views 6.x-2.12 and CCK 6.x-2.9 so that didn't work

Then one of the posters in one of the like 12 threads I read said it worked with Views 6.x-2.11 and CCK 6.x-3.x-dev so I was going to try that but for some reason I got CCK 6.x-3.0-alpha1 and Views 6.x-2.11 but that didn't work either.

So I went back to Views 6.x-2.12 and CCK 6.x-2.9 and then I posted here.

So when I read your comment I tried CCK 6.x-3.x-dev and that didn't work. Then I noticed you actually said Views 6.x-3.x-dev.

So now I have CCK 6.x-3.x-dev, Views 6.x-3.x-dev, I still get the same result... meaning the view works fine, I see the correct data, the cck field I only get one result with the wrong nid but now I get a huge error box in the cck:

warning: Invalid argument supplied for foreach() in /home/kevin/public_html/seniorassist/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 921.

warning: Invalid argument supplied for foreach() in /home/kevin/public_html/seniorassist/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 997.

warning: Invalid argument supplied for foreach() in /home/kevin/public_html/seniorassist/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 921.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM node node INNER JOIN users users ON node.uid = users.uid INNER JOIN node' at line 2 query: SELECT DISTINCT FROM node node INNER JOIN users users ON node.uid = users.uid INNER JOIN node node_users ON users.uid = node_users.uid AND node_users.type = 'cp_senior' INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 24 AND na.realm = 'content_access_author') OR (na.gid = 2 AND na.realm = 'content_access_rid') OR (na.gid = 9 AND na.realm = 'content_access_rid'))) AND ( (users.status <> 0) AND (node_users.nid = 16 ) ) LIMIT 0, 1 in /home/kevin/public_html/seniorassist/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1144.

I don't get any errors in the view, only in the cck page.

Any other suggestions?

drupalsven’s picture

I have a similar issue in cennection with the user_relationships module.
I want a list of related users. This is the Views query:

SELECT users.uid AS uid,
   users_user_relationships.name AS users_user_relationships_name
FROM users users
LEFT JOIN user_relationships user_relationships ON users.uid = user_relationships.requestee_id
LEFT JOIN users users_user_relationships ON user_relationships.requester_id = users_user_relationships.uid
WHERE (user_relationships.rtid in ('1', '2')) AND (user_relationships.requestee_id = ***CURRENT_USER***)

This gives me the correct number of results in the Views Preview. However, on the CCK select list only the last entry of the query is displayed.

The "add the uid field"-workaround (http://drupal.org/node/896874#comment-3823332) did not work for me.

This is on the 6.2.12 Views and the 6.2.9 CCK.

vilepickle’s picture

Same problem as 22. The views preview works fine, the noderef with a Node Title argument being sent only shows the last entry of the query.

I am using the 3.x dev of Views as well.

vilepickle’s picture

To reproduce:

Views 6.x-2.12
CCK 6.x-3.0-alpha3
(I have tried with combinations of Views 6.3x dev, CCK 2.9, etc. No fix with my scenario.)

You'll make 3 content types.

Make a content type:
course

Import the following session content type:

$content['type']  = array (
  'name' => 'Session',
  'type' => 'session',
  'description' => '',
  'title_label' => 'Title',
  'body_label' => 'Body',
  'min_word_count' => '0',
  'help' => '',
  'node_options' =>
  array (
    'status' => true,
    'promote' => true,
    'sticky' => false,
    'revision' => false,
  ),
  'old_type' => 'session',
  'orig_type' => '',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
);
$content['fields']  = array (
  0 =>
  array (
    'label' => 'Courses',
    'field_name' => 'field_courses',
    'type' => 'nodereference',
    'widget_type' => 'nodereference_select',
    'change' => 'Change basic information',
    'weight' => '31',
    'autocomplete_match' => 'contains',
    'size' => 60,
    'description' => '',
    'default_value' =>
    array (
      0 =>
      array (
        'nid' => '',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' => NULL,
    'group' => false,
    'required' => 1,
    'multiple' => '1',
    'referenceable_types' =>
    array (
      'course' => 'course',
      'page' => 0,
      'registration' => 0,
      'session' => 0,
      'story' => 0,
      'courseselection' => false,
    ),
    'advanced_view' => '--',
    'advanced_view_args' => '',
    'op' => 'Save field settings',
    'module' => 'nodereference',
    'widget_module' => 'nodereference',
    'columns' =>
    array (
      'nid' =>
      array (
        'type' => 'int',
        'unsigned' => true,
        'not null' => false,
        'index' => true,
      ),
    ),
    'display_settings' =>
    array (
      'label' =>
      array (
        'format' => 'above',
        'exclude' => 0,
      ),
      'teaser' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'full' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      4 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  ),
);
$content['extra']  = array (
  'title' => '-5',
  'body_field' => '0',
  'revision_information' => '20',
  'author' => '20',
  'options' => '25',
  'menu' => '-2',
  'path' => '30',
);

Add 3 demo courses, 1 session. In the session make sure to reference TWO course nodes (important for viewing bug)

Import 1 view:

$view = new view;
$view->name = 'courses_registration_session';
$view->description = '';
$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('relationships', array(
  'field_courses_nid' => array(
    'label' => 'Courses',
    'required' => 1,
    'delta' => '-1',
    'id' => 'field_courses_nid',
    'table' => 'node_data_field_courses',
    'field' => 'field_courses_nid',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'title' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'field_courses_nid',
  ),
));
$handler->override_option('arguments', array(
  'title' => array(
    'default_action' => 'not found',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'none',
    'transform_dash' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'course' => 0,
      'courseselection' => 0,
      'page' => 0,
      'registration' => 0,
      'session' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(),
    '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(
      'session' => 'session',
    ),
    '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('cache', array(
  'type' => 'none',
));

Import the following for courseselection content type:

$content['type']  = array (
  'name' => 'Course Selection',
  'type' => 'courseselection',
  'description' => '',
  'title_label' => 'Title',
  'body_label' => '',
  'min_word_count' => '0',
  'help' => '',
  'node_options' =>
  array (
    'status' => true,
    'promote' => true,
    'sticky' => false,
    'revision' => false,
  ),
  'old_type' => 'courseselection',
  'orig_type' => '',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
);
$content['fields']  = array (
  0 =>
  array (
    'label' => 'Session 5',
    'field_name' => 'field_session5',
    'type' => 'nodereference',
    'widget_type' => 'nodereference_buttons',
    'change' => 'Change basic information',
    'weight' => '-4',
    'autocomplete_match' => 'contains',
    'size' => 60,
    'description' => '',
    'default_value' =>
    array (
      0 =>
      array (
        'nid' => '',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' => NULL,
    'group' => false,
    'required' => 1,
    'multiple' => '0',
    'referenceable_types' =>
    array (
      'course' => 0,
      'courseselection' => 0,
      'page' => 0,
      'registration' => 0,
      'session' => 0,
      'story' => 0,
    ),
    'advanced_view' => 'courses_registration_session',
    'advanced_view_args' => 'Session 5',
    'op' => 'Save field settings',
    'module' => 'nodereference',
    'widget_module' => 'nodereference',
    'columns' =>
    array (
      'nid' =>
      array (
        'type' => 'int',
        'unsigned' => true,
        'not null' => false,
        'index' => true,
      ),
    ),
    'display_settings' =>
    array (
      'label' =>
      array (
        'format' => 'above',
        'exclude' => 0,
      ),
      'teaser' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'full' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      4 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  ),
);
$content['extra']  = array (
  'title' => '-5',
  'revision_information' => '-2',
  'author' => '-1',
  'options' => '0',
  'menu' => '-3',
  'path' => '1',
);

Go and try to create a course selection content type. You'll see that only ONE option comes up in the nodereference that sources the view. The view has a relationship and uses Node Title as the argument (defined in the course_selection Session 5 nodereference field). When you test out the view in preview with "Session 5" you get the full list of course nodes.

vilepickle’s picture

In CCK nodereference.module, this line is the first occurrence of the results only returning 1 when there are more:

$result = $view->execute_display($display, $view_args);

In function _nodereference_potential_references_views()

I don't have enough experience with Views to know what the problem is right away. I will be digging, but if anyone has quick insight it would be nice.

vilepickle’s picture

My solution to this isn't pretty but I made it work. It involves hacking the Views handler for nodereferences as well as using the nid workaround in the View. It also involves hardcoding the relationship nid field in the views handler so it thinks that nid is what it should use for the referenced fields.

I'd post it but it's definitely not the right way to fix this problem. I think what is required is an implementation of relationship recognition in the nodereference views handler since that doesn't seem to exist at all (oversight?).

Azol’s picture

Component:nodereference.module» Views Integration

I wonder at the lack of input from developers since this seems to be quite a wide-spread issue; changing this to Views Integration issue, as we cannot be sure it's completely on the noderef's side.
Ah, and one more: the same problem exists for user reference field.

vilepickle’s picture

Actually, I think it's more a CCK thing. Views happily returns the right results if using other views handlers. Using the noderef handler that interacts with Views, however, means that relationships aren't accounted for if they exist in the view.

I could be wrong though, but I assume it's up to that noderef handler to find out about relationships that exist in the view.

All of the tweaks I did to make this work were made in the CCK noderef (the views handler and the main module) code and not in Views. The only thing I did in Views is also reference the relationship's nid as a field so the CCK noderef handler could access it more easily. This is obviously very hacky and not the right way to fix this long term...

Azol’s picture

The problem is the code in user/node reference hasn't change much, but it is after upgrading Views that the problem arise: all of a sudden you should start adding NID to your old views to return more than 1 result (undocumented) and so on. The code in CCK looks okay to me and it still creates the new display with limit=0 for the view you choose (#13), but the integration between these two modules is broken, or Views does not respect this setting now. I tried to debug this thing over and over to find out what happens to no avail, due to the fact Views is a pretty complicated module and I lack the knowledge of its structure and the data it uses. Instead, I just refuse to do any CCK or Views upgrades on production sites until this issue is fully resolved.

vilepickle’s picture

Here's my hack if anyone here is curious. I don't recommend it if you're using noderef views for a lot of other things, but it's nice if you want it for just a select few and need more than 1 result returned from a view with a relationship and argument...

cck/modules/nodereference/nodereference.module
~line 230, comment this portion out. This is the part I'm a little scared about since I'm removing some validation to push the relationships through

            /* Vilepickle hack 6/8, removed because it would always error out on relationships */
            /*if (!empty($item['nid']) && !isset($refs[$item['nid']])) {
              form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label']))));
            }
             */
            /* Vilepickle hack 6/8 */

cck/includes/views/handlers/content_plugin_style_php_array_ac.inc
Copy of the entire file, I have indicated my hacky parts.

<?php

/**
* @file
* Handler for 'content_php_array_autocomplete' style.
*/
class content_plugin_style_php_array_ac extends views_plugin_style {

  function render () {
    $results = array ();

    // Group the rows according to the grouping field, if specified.
    $sets = $this->render_grouping ($this->view->result, $this->options['grouping']);

    $base_field = $this->view->base_field;

    /* Vilepickle hack 6/8 */
    if ($this->view->relationship) {
      $base_field = 'course';
    }
    /* Vilepickle hack 6/8 */

    $title_field = $this->display->display_options['content_title_field'];
    $title_field_alias = $this->view->field[$title_field]->field_alias;
    //dpm ($this->view);

    // TODO : We don't display grouping info for now.
    // Could be useful for select widget, though.
    $this->view->row_index = 0;
    foreach ($sets as $title => $records) {
      foreach ($records as $label => $row) {

       /* Vilepickle hack 6/8 */
        if ($base_field == 'course') {
          //This is hardcoded :(
          //Assign the nid to the correct NID for a relationship, field is specific to this reference...
          $row->nid = $row->node_node_data_field_courses_nid;
          $results[$row->nid] = array (
              'title' => $row->{$title_field_alias},
              'rendered' => $this->row_plugin->render ($row),
          );
         
        } else {
          //run the old code that doesn't do anything with relationships
          $results[$row->{$base_field}] = array (
              'title' => $row->{$title_field_alias},
              'rendered' => $this->row_plugin->render ($row),
          );
        }
        /* Vilepickle hack 6/8 */
       
        $this->view->row_index++;
      }
    }
    unset ($this->view->row_index);
    return $results;
  }

}

The very specific portion of this is "node_node_data_field_courses_nid" which is the view reference for my relationship's NID. You'd have to add a new one in for each different view you use in a nodereference. I got that exact name by using devel and dpm()

seagle’s picture

To implement solution #13 -

Where do I add the NID? I have a main view with my selected fields, including my node reference field. The relationship is set on the node reference field and I'm successfully pulling a single result from one of the fields found in the referenced nodes. Problem is there are many more then one node referenced per each primary node...

Not sure where to add the NID to fix this. I've tried to add it as a field and its not an option in Relationships. If I'm supposed to add it in filters, how should I configure it?

Any advice would be great, thanks.
Running Drupal 7.12, Views 7.x-3.3, and References 7.x-2.0

Azol’s picture

The View you use returns the LIST of the nodes for your CCK Nodereference widget. You should add the Node:NID field (and set it to be hidden, as you normally do not care about NIDs). The NIDs should refer the nodes in question.

Azol’s picture

To elaborate:
1) you have a node reference field in content A, referencing content B nodes using some view. Correct?
2) I cannot see the Master display in your view, that means you should go to Views settings and turn the "Always show the master display" feature on.
2) Edit the view you are using to generate the list of nodes of content type B to add "Content: NID" field to Master display of the view (mark it as Exclude from View). Do not use any references in your view for this field.
3) Save the view and create new node of content type A - can you see more than 1 result in node reference list?

seagle’s picture

I am generating the multiple Node ID's from the referenced content B if I chose Formatter - 'Node ID' for the referenced node. If I setup the view to display all instances of content A and add the field Content:NID, then I just get the NID for the content A node. If I add the relationship I just get the first instance of the referenced Content B's.

The problem is for each instance of content A I want to render the following fields:
A - title
A - body
B - image (multiple nodes referenced should give me multiple images)

I cannot figure out how to render the multiple images from content B, even though I am seeing the multiple Node ID's. I did notice that if I change the Formatter for the noderef field to 'Rendered Node' I am offered 'View Mode' but none of these give me just the formatted image. I'm looking into either creating a custom View Mode or a View generated node reference.

Azol’s picture

1st of all, check the CCK settings for your node reference field. Which view do you use to populate the list?

seagle’s picture

Okay, that worked but it required the involvement of yet another module - Display Suite. I created a new View Mode in Display suite, enabled it, hid everything in the referenced content type accept the image field. Now when I pull in the Content B field in my view I can select 'Rendered Node' and then select my new View Mode 'Product Images' boom, I only see images and I get all of them. I have a feeling that this is one of the least elegant routes to take but it worked.

Azol’s picture

Seems like a Views issue to me, not CCK-related. Glad you were able to sort it out finally.

seagle’s picture

Thank Azol for putting so much time into this!

sirpy’s picture

This bug happens when using a view to choose nodes that are filtered by node reference relationship.
because the main node (the one that contains a reference to the nodes we want) is used as each of the results NID, cck treats it as only 1 result.
I've been able to use the node reverse reference module to get the expected results.