Hello, i used Nodereference 6.x-2.2 and this moduel works only with 1item in the nodereference field. Is it true? Maybe you can reproduce this. So wrote a little patch. Please comment.


function theme_nodereference_views_formatter_views($element) { 
  // We get here even if the field is empty, so check that the 0 value is not a proper nid
  // and return nothing so the label is not shown.
  
  $field = $element['#field_name'];
  
  foreach($element['#node']->$field as $k => $v) {
    if($v['nid'] != "") {
      $nids[] = $v['nid'];
    }
  }
  
  if($nids) {  
    $arg_nids = implode(',', $nids);
  } else {
    $arg_nids = array();
  }
  
  // Don't use views_embed_view so we can return an error if the view can't be found.
  $view_name  = $element['#field_name'];
  $args       = array($arg_nids);
  
  $view = views_get_view($view_name);
  if (!$view) {
    return "Error: view $view_name not found.";
  }

  return $view->preview('default', $args);
}

Comments

joachim’s picture

Weird. I'm on CCK 6.x-2.2 too and it works fine.
Could you do a debug output with dsm($element) and paste it here please? (You'll need devel.module for that).

webflo’s picture

avoid invalid arguments with is_numeric

joachim’s picture

Status: Active » Fixed

I've fixed this, but I think this is also a bug in CCK: http://drupal.org/node/422036

Can you try the dev release once it appears and let me know if it's fixed your problem?

webflo’s picture

your patch works fine. no problems with empty items from nodereference field. thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

webel’s picture

2010-03-26: The entire matter (below) was a wild goose chase. The entire problem was that in the view (for some unknown reason) the setting Allow multiple terms per argument for the view argument Node: Nid was not checked TRUE. Please read however my remarks about what I feel about how unnecessarily hard it is to investigate certain problems in Drupal sometimes, because of the way it is coded. I have apologised to maintainer joachim for wasting his time. Dr Darren Kelly (Webel IT Australia)

Reopening w.r.t. following module versions:

Node reference views 6.x-1.2

Views 6.x-2.x-dev

Content 6.x-2.x-dev

Please see 2 attached images, the 1st shows 3 referenced nodes as title links for a field 'field_defining_document'
(happens to be displayed within a Fieldgroup), the 2nd shows the result with NodeReferenceViews,
and I've tested the 2nd and 3rd referenced nodes by arg %nid directly in the view 'field_defining_document' already
in the Views UI, it runs fine, NodeReferenceViews is clearly not iterating over all referenced nodes, just the first.

Grateful for any feedback, Webel

webel’s picture

Version: 6.x-1.0 » 6.x-1.2
Status: Closed (fixed) » Active

bumping.

joachim’s picture

Could you debug to check the noderef field formatter is getting all the nids, and likewise the view argument handler is getting them?

webel’s picture

Hi, am resuming investigation of this.

nodereference_views.module,v 1.4 2009/07/14 20:42:19 joachim

Copying and pasting the Krumo output of dsm($element) at entry to theme_nodereference_views_formatter_views($element):

... (Array, 13 elements)
#type_name (String, 11 characters ) methodology
#formatter (String, 5 characters ) views
#node (Object) stdClass
#field_name (String, 23 characters ) field_defining_document
#theme (String, 35 characters ) nodereference_views_formatter_views
0 (Array, 2 elements)
#item (Array, 1 element)
nid (String, 4 characters ) 2664
#weight (Integer) 0
1 (Array, 2 elements)
#item (Array, 1 element)
nid (String, 4 characters ) 2667
#weight (Integer) 1
2 (Array, 2 elements)
#item (Array, 1 element)
nid (String, 4 characters ) 2669
#weight (Integer) 2
#title (NULL)
#description (NULL)
#theme_used (Boolean) TRUE
#value (String, 0 characters )
#type (String, 6 characters ) markup

As you can see, in this case there are three referenced nids: 2664, 2667, 2669.

I continued debugging stage by stage:

  foreach (element_children($element) as $key) {
    $nids[] = $element[$key]['#item']['nid'];
  }
  dsm($nids); ///Webel: DEBUG

This gave correctly the 3 nids within an array:

... (Array, 3 elements)
0 (String, 4 characters ) 2664
1 (String, 4 characters ) 2667
2 (String, 4 characters ) 2669

And then:

  // Filter out NULL values from gappy fields: see http://drupal.org/node/422036
  $arg_nids = implode(',', array_filter($nids));
  dsm($arg_nids); ///Webel: DEBUG

This yields not an array of nids, rather a string with comma separated nid strings:

2664,2667,2669

The above is literal, i.e. it is one string with commas between numeric characters.
I can't imagine why on earth anybody would ever want to handle args like that
(and I looked at http://drupal.org/node/422036). Continuing through:

  // Don't use views_embed_view so we can return an error if the view can't be found.
  $view_name  = $element['#field_name'];
  $args[]     = $arg_nids;
  $args[]     = $element['#node']->nid;
  dsm($args); ///Webel: DEBUG

Gives:

... (Array, 2 elements)
0 (String, 14 characters ) 2664,2667,2669
1 (String, 4 characters ) 2662

Which eventually gets passed to:

  return $view->preview('default', $args);
joachim’s picture

Status: Active » Postponed (maintainer needs more info)

> I can't imagine why on earth anybody would ever want to handle args like that

Because that is the only way to do it! The Views node ID argument has to have all the values in a single string it can recognize.

Everything is working as it should so far.
Are you on the latest version of Views?
What does the node ID argument receive?

webel’s picture

Status: Postponed (maintainer needs more info) » Active

I googled around '$view->preview' without success to find out why one might pass the nid args as '2664,2667,2669', and am none the wiser. I tried naively overriding the implode trick with $arg_nids, thus:

  //ORIG $args[]     = $arg_nids;
  $args     = $nids;///Webel: DEBUG
  $args[]     = $element['#node']->nid;
  dsm($args); ///Webel: DEBUG

It gives as expected an array with 4 elements, where the first three are the referenced nids, and the last is the nid of the page in which the nodereferenceview should appear.

... (Array, 4 elements)
0 (String, 4 characters ) 2664
1 (String, 4 characters ) 2667
2 (String, 4 characters ) 2669
3 (String, 4 characters ) 2662

The served page still only shows a view result for the first nid, in this case 2664.

webel’s picture

@joachim
Thanks for the world's fastest response, and I now understand why you are using the implode trick (although I do not understand why preview needs to be fed that way).
Although I know plenty of PHP, I am a UML+Java person, and I find the way arguments and functions as names hidden within arrays are thrown around in Drupal infuriating and mostly unnecessary, and sometime just plain sloppy. It drives me crazy.

Am looking into direct args fed to Views UI, will report back in minutes ...

webel’s picture

@joachim If I am to test directly (again) in the Views UI admin page for the view field_defining_document (which can be multiple), what would you expect me to feed into the dialog ? The interface requests:

Separate arguments with a / as though they were a URL path.

I know of course how Views and View UI work, I use them every day, however I do not know whether this relates directly to $view->preview

webel’s picture

Where can I find out what $view->preview('default',$args) expects ? Is it documented as part of the API ? And if so where ?

webel’s picture

BTW I have also done a lot of direct embedding of views in .tpl.php templates for custom types, I'm quite familiar with programmatic embedding of views.

webel’s picture

For the record, in views/includes/view.inc:

  /**
   * Preview the given display, with the given arguments.
   *
   * To be called externally, probably by an AJAX handler of some flavor.
   * Can also be called when views are embedded, as this guarantees
   * normalized output.
   */
  function preview($display_id = NULL, $args = array()) {
    if (empty($this->current_display) || $this->current_display != $display_id) {
      if (!$this->set_display($display_id)) {
        return FALSE;
      }
    }

    $this->preview = TRUE;
    $this->pre_execute($args);
    // Preview the view.
    $output = $this->display_handler->preview();

    $this->post_execute();
    return $output;
  }

  /**
   * Run attachments and let the display do what it needs to do prior
   * to running.
   */
  function pre_execute($args = array()) {
    $this->old_view[] = views_get_current_view();
    views_set_current_view($this);
    $display_id = $this->current_display;

    // Let modules modify the view just prior to executing it.
    foreach (module_implements('views_pre_view') as $module) {
      $function = $module . '_views_pre_view';
      $function($this, $display_id, $args);
    }

    // Prepare the view with the information we have, but only if we were
    // passed arguments, as they may have been set previously.
    if ($args) {
      $this->set_arguments($args);
    }

//    $this->attach_displays();

    // Allow the display handler to set up for execution
    $this->display_handler->pre_execute();
  }

webel’s picture

It is completely unclear to me how that (including the docs) relates to the expectation to be fed an array with two elements, the first being itself an array of referenced node nids, and the last being the nid of the page to be served into, and if that is so, then why is that not documented ?

joachim’s picture

You need to find the actual handler file for the node ID argument handler, and find what it's getting fed to it by Views as its value.

> Separate arguments with a / as though they were a URL path.

Just what it says, so concatenate this array with slashes:

... (Array, 2 elements)
0 (String, 14 characters ) 2664,2667,2669
1 (String, 4 characters ) 2662

joachim’s picture

Are you sure you're on the latest Views? IIRC older versions didn't support multiple nids on that arg.

webel’s picture

Back reference to forum topic: Drupal and object-orientation, design against contract, and method name manipulation tricks. Please keep the remarks below within the context of this issue, although the remarks below have nothing to do with the coding of this particular module by its maintainers. Rather, these remarks are about what is being coded against by such contributors, except that contributing coders are encouraged to mimic such.

ASIDE: this is the kind of thing I am talking about (often elsewhere on Drupal.org as an ongoing theme) that drives me mad when working with Drupal code, nearly all of it, core and contributed, and it has nothing to do with PHP (which has excellent object-oriented support and class and interface handling features and the ability to design against interface contracts), at all, it is simply Drupal culture, a trick that has become an obsessive anti-pattern:

    // Let modules modify the view just prior to executing it.
    foreach (module_implements('views_pre_view') as $module) {
      $function = $module . '_views_pre_view';
      $function($this, $display_id, $args);
    }

I realise fully that this code comes from Views developers, and how important that module is (and how much work it does for my life). There is absolutely no need (except for in Drupal culture) to play games like that with method names. None.

There are some nice things one can do because on can manipulate function names and pass them around, but this example above is not one of them.

Just because one can manipulate functions as names and pass them around in PHP does NOT mean that it is a good idea to always do it. The code above is essentially repeating what object-oriented structures enable us to avoid. I would like every single Drupal developer to read this and know: I don't think you, any of you, should be or need to keep doing that, and I find the way Drupal is coded so bad at times that I really have to ask seriously whether I can stay with the technology, even when it now runs many sites for me (some of which ironically teach advanced graphical object-orientation for UML+Java).

I want to, seriously, completely rewrite all of Drupal from top to bottom, because I am weary of tricks like this.

Dr Darren Kelly (Webel)

If you came here from the forum please return to: http://drupal.org/node/752710

webel’s picture

@ joachim
> Are you on the latest version of Views?
No. Views 6.x-2.x-dev.

// $Id: views.module,v 1.341.2.3 2009/12/24 00:02:59 merlinofchaos Exp $

> What does the node ID argument receive?
Which node ID argument of what received where ?
Please specify:module, function, line etc.

Very grateful for your persistence,

Webel

joachim’s picture

Drupal's hook system dates back to before PHP's decent OO support. I have grown to rather like the hook system myself. Besides, I'm not even sure how you'd do that pattern with OO, as the hook pattern can allow several modules to chime in and make changes.

sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc

and there you are in the delights of OO, as you chase up the class tree until you find the function that actually accepts the particular argument value for that handler.

webel’s picture

Aside: @joachim

> I'm not even sure how you'd do that pattern with OO

Which is probably like most Drupal developers. I do know how to do it, very elegantly and simply, and a lot more, and want to one day get every single major core developer and any contributors like you together in a room to show you better ways, ways that also bring with them incredible other powers, as well as correspondence with graphical patterns (the point being that you get to use more than just the code-friendly part of your brains, it is a cognitive matter).

webel’s picture

I will install latest views and get back ..

webel’s picture

> Are you on the latest version of Views?

The latest recommended version is:

http://drupal.org/node/649642
views-6.x-2.8.tar.gz
Last updated: December 3, 2009 - 10:16

That would seem to be older than the devel version I have from:

// $Id: views.module,v 1.341.2.3 2009/12/24 00:02:59 merlinofchaos Exp $

I do not wish to re-install views now, I can recall I had to upgrade because of another problem and can't afford to influence that right now (because of client).

Could you please check for me against: views-6.x-2.8.tar.gz

I might be able to perform a check on a local version (without disrupting my client's access to the devel site) against views-6.x-2.8.tar.gz.

joachim’s picture

In which case, your avenue is to figure out why the handler either gets the wrong data or doesn't handle it correctly.

webel’s picture

@joachim With all respect and gratitude for our efforts, it is not my avenue. I am not the maintainer of your module, nor or views, and I have spent many hours now dealing with this matter (as so often lately with Drupal problems) without a solution, and the onus is not on me, and nobody could claim I have not done what I can to help myself, now can they ? I have read what a module is supposed to be able to do, I have correctly followed instructions for how I am supposed to achieve it, and it is not working. And whether it is free or not is of little interest to my paying client who would find it hard to understand why any modern system would not be able to query a database for some results and display them if there is more than one hit.

Could you please now give PRECISE instructions as to what I at my end should diagnose (having done lots already tonight), and please this time say:

WHICH handler

WHICH module

WHICH methods

You are being too vague, and it is wasting both of our time, and it costs money that I can't bill to a client.

Darren Kelly (Webel)

webel’s picture

Please provide one example of:

A type with a reference to more than one instance of another type (the hits).

A view compatible with your module that can correctly display these many hits on referenced nodes (derived as we are instructed from the special view to be cloned).

A served web page proving that it works.

The precise combination of modules with version numbers.

Webel.

webel’s picture

joachim wrote:

just what it says, so concatenate this array with slashes:

... (Array, 2 elements)
0 (String, 14 characters ) 2664,2667,2669
1 (String, 4 characters ) 2662

No, would YOU please concatenate this array with slashes and show me.
I asked you to please show what to feed into the Views UI preview.

The array has 2 elements, one of which is a strange string with commas between nids, so does this mean '2664,2667,2669/2662' ?

Because that certainly does not work entered in the arguments field of my view
(field_defining_document) which was cloned and adapted from your example view provided with the module.

Q: Is there anything special one has to do make that clonable example work with multiple references ?

Please provide an actual example that works. And please be precise.

Webel

webel’s picture

All of my field_ views are cloned from the example provided by the module. Here is just one of the views I have that are not able to handle multiple node references driven by your module. Please examine it and confirm whether it should work:

$view = new view;
$view->name = 'field_defining_document';
$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(
  'upload_fid' => array(
    'label' => 'Files',
    'required' => 0,
    'id' => 'upload_fid',
    'table' => 'node',
    'field' => 'upload_fid',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Document title',
    '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,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_document_number_value' => array(
    'label' => 'Identifier',
    '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,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'custom',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_document_number_value',
    'table' => 'node_data_field_document_number',
    'field' => 'field_document_number_value',
    'relationship' => 'none',
  ),
  'field_computed_date_published_value' => array(
    'label' => 'Document date',
    '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,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'custom',
    'format' => 'computed_value',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_computed_date_published_value',
    'table' => 'node_data_field_computed_date_published',
    'field' => 'field_computed_date_published_value',
    'relationship' => 'none',
  ),
  'field_standard_status_value' => array(
    'label' => 'Status',
    '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,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 1,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'custom',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_standard_status_value',
    'table' => 'node_data_field_standard_status',
    'field' => 'field_standard_status_value',
    'relationship' => 'none',
  ),
  'filesize' => array(
    'label' => 'Size',
    '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,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 1,
    'empty_zero' => 0,
    'file_size_display' => 'formatted',
    'exclude' => 0,
    'id' => 'filesize',
    'table' => 'files',
    'field' => 'filesize',
    'relationship' => 'upload_fid',
  ),
  'filemime' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => '<img class="mimetype-img" src="/sites/ppi.webel.com.au/themes/ppi/mimetype/[filemime].gif"/>',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 1,
    'empty_zero' => 0,
    'link_to_file' => 0,
    'exclude' => 0,
    'id' => 'filemime',
    'table' => 'files',
    'field' => 'filemime',
    'relationship' => 'upload_fid',
  ),
  'upload_fid' => array(
    'label' => 'Files',
    'alter' => array(
      'alter_text' => 1,
      'text' => 'DOWNLOAD!',
      'make_link' => 1,
      'path' => 'system/files/private/[upload_fid-name]',
      'link_class' => 'download',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 1,
    'empty_zero' => 0,
    'type' => 'separator',
    'separator' => ', ',
    'link_to_file' => 0,
    'only_listed' => 0,
    'exclude' => 0,
    'id' => 'upload_fid',
    'table' => 'node',
    'field' => 'upload_fid',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'nid' => array(
    'default_action' => 'empty',
    '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',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '7' => 0,
      '8' => 0,
      '3' => 0,
      '6' => 0,
      '4' => 0,
      '5' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'blog' => 0,
      'g2_entry' => 0,
      'image' => 0,
      'book' => 0,
      'component' => 0,
      'definition' => 0,
      'document' => 0,
      'external' => 0,
      'feature' => 0,
      'help' => 0,
      'issue' => 0,
      'journal' => 0,
      'linkblock' => 0,
      'methodology' => 0,
      'module' => 0,
      'moe' => 0,
      'organisation' => 0,
      'page' => 0,
      'person' => 0,
      'property' => 0,
      'publisher' => 0,
      'question' => 0,
      'requirement' => 0,
      'snippet' => 0,
      'story' => 0,
      'tip' => 0,
      'wikipedia' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '3' => 0,
      '5' => 0,
      '4' => 0,
      '2' => 0,
      '6' => 0,
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'validate_argument_php' => '',
  ),
  'null' => array(
    'default_action' => 'ignore',
    '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',
    'must_not_be' => 0,
    'id' => 'null',
    'table' => 'views',
    'field' => 'null',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '7' => 0,
      '8' => 0,
      '3' => 0,
      '9' => 0,
      '6' => 0,
      '4' => 0,
      '5' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'blog' => 0,
      'image' => 0,
      'definition' => 0,
      'book' => 0,
      'component' => 0,
      'defined_term' => 0,
      'document' => 0,
      'external' => 0,
      'feature' => 0,
      'help' => 0,
      'issue' => 0,
      'journal' => 0,
      'linkblock' => 0,
      'methodology' => 0,
      'module' => 0,
      'moe' => 0,
      'organisation' => 0,
      'page' => 0,
      'person' => 0,
      'property' => 0,
      'publisher' => 0,
      'question' => 0,
      'quotation' => 0,
      'requirement' => 0,
      'snippet' => 0,
      'story' => 0,
      'tip' => 0,
      'wikipedia' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '3' => 0,
      '8' => 0,
      '5' => 0,
      '4' => 0,
      '2' => 0,
      '6' => 0,
      '1' => 0,
      '7' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'document' => 'document',
      'external' => 'external',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 0);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'title' => 'title',
    'field_document_number_value' => 'field_document_number_value',
    'field_computed_date_published_value' => 'field_computed_date_published_value',
    'field_standard_status_value' => 'field_standard_status_value',
    'filesize' => 'filesize',
    'filemime' => 'filemime',
    'upload_fid' => 'upload_fid',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'field_document_number_value' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'field_computed_date_published_value' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'field_standard_status_value' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'filesize' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'filemime' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'upload_fid' => array(
      'separator' => '',
    ),
  ),
  'default' => 'title',
));
$handler->override_option('row_options', array(
  'inline' => array(),
  'separator' => '',
  'hide_empty' => 1,
));
joachim’s picture

Category: bug » support

> @joachim With all respect and gratitude for our efforts, it is not my avenue. I am not the maintainer of your module, nor or views, and I have spent many hours now dealing with this matter (as so often lately with Drupal problems) without a solution, and the onus is not on me, and nobody could claim I have not done what I can to help myself, now can they ? I have read what a module is supposed to be able to do, I have correctly followed instructions for how I am supposed to achieve it, and it is not working. And whether it is free or not is of little interest to my paying client who would find it hard to understand why any modern system would not be able to query a database for some results and display them if there is more than one hit.

Sorry; I should have made it clear. The module works perfectly for me -- this is a support request not a bug report. I've just tried it to double-check. I've no idea how you've managed to break it. I've already given you the exact filename for the handler and a plan of attack -- it gets fed a value from the array of arguments by Views. The code may be free, but you're getting paid to figure this out; I am not and to boot I have other work to be getting on with.

webel’s picture

> The code may be free, but you're getting paid to figure this out;

NO I AM NOT getting paid for it. I don't, and can't, bill this to a client. And I have spent nearly 1 month (entire month) over 6 months on this particular project, unpaid, trawling through problems that I did not cause fixing other people's problems. And most of them could have been avoided by simple object-orientation and basic defensive programming practices that are not being used enough.

webel’s picture

> The module works perfectly for me

Then please now do as I have asked and show an example, with each and every element required to display multiple references.

webflo’s picture

I posted a view in http://drupal.org/node/528756#comment-2768150
Here is my setup: Node reference views 6.x-1.2 + CCK 6.x-2.6 + Views 6.x-2.8

webel’s picture

Category: support » bug

@joachim

I am changing this to a bug report. Until I can see an example of it working (including version combinations) I will remain convinced it is bug (rather than that I have 'managed to break it' as you put it. It may be that I have overlooked something very simple in the use of the module, however since I don't have yet have another example to compare with there is no way of knowing.

I now find myself (again) essentially debugging within Views. If you, joachim, feel that this is a Views bug then by all means move it to the View queue, but please not before your have provided an example, instead of just insisting that it works.

> I've already given you the exact filename for the handler ...
You said (in the context of the Drupal hook system, without saying precisely how it relates to the code of this module or to this problem):

sites/all/modules/views/modules/node/views_handler_argument_node_nid.inc

and there you are in the delights of OO, as you chase up the class tree until you find the function that actually accepts the particular argument value for that handler.

A filename is not a method, but when we (I) crack it open, one finds:

// $Id: views_handler_argument_node_nid.inc,v 1.1 2008/09/03 19:21:29 merlinofchaos Exp $
/**
 * @file
 * Provide node nid argument handler.
 */

/**
 * Argument handler to accept a node id.
 */
class views_handler_argument_node_nid extends views_handler_argument_numeric {
  /**
   * Override the behavior of title(). Get the title of the node.
   */
  function title_query() {
    $titles = array();
    $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));

    $result = db_query("SELECT n.title FROM {node} n WHERE n.nid IN ($placeholders)", $this->value);
    while ($term = db_fetch_object($result)) {
      $titles[] = check_plain($term->title);
    }
    return $titles;
  }
}

Now how please is that "a plan of attack". Am I supposed to be looking into title_query() ? Well clearly I know I am not, however I have still not been told exactly what to do. And with over 30 years coding experience, I am usually quite easy to tell what to do, the point being I know full well how to (as I have so often had to with Drupal code) trawl through it like personal tracing machine.

I was told:

> What does the node ID argument receive?

I am guessing that you are referring to the above, however although this class file says that it is an 'Argument handler to accept a node id.' there is nowhere else any mention of node ids.

> Drupal's hook system dates back to before PHP's decent OO support.
Well then it is not a surprise that I find it outdated then (dare I say primitive).

> and there you are in the delights of OO
No. Never, not once, when working with Drupal, I am in the delights of OO. I adore OO. It is a major focus of my long professional career, and my entire organism at time screams for a Java CMS that has a strong community like Drupal, yet embraces delightful OO and admits use of graphical UML tools and advanced features of modern IDEs more easily, and would waste less of my time.

webel’s picture

I opened up the extended class:

// $Id: views_handler_argument_numeric.inc,v 1.1 2008/09/03 19:21:28 merlinofchaos Exp $
/**
 * @file
 * Contains the numeric argument handler.
 */

/**
 * Basic argument handler for arguments that are numeric. Incorporates
 * break_phrase.
 *
 * @ingroup views_argument_handlers
 */
class views_handler_argument_numeric extends views_handler_argument {
..

And I'm none the wiser about how I can diagnose within that find out why my nodereferenceviews with multiple references only show one item.

webel’s picture

@webflo

Thanks for prompt reply with precise view example and version numbers.

You wrote:
> Here is my setup: Node reference views 6.x-1.2 + CCK 6.x-2.6 + Views 6.x-2.8
I have Node reference views 6.x-1.2, Content 6.x-2.6, and Views 6.x-2.x-dev (apparently from after release of Views 6.x-2.8)

To be completely fair I will obviously now have downgrade Views back to 6.x-2.8 for precise comparison (luckily i have a local version of my remote devel site, so I can experiment a bit). Will report back.

webel’s picture

@joachim

At http://drupal.org/node/528756#comment-2691600 you wrote:

I am very busy with paid work, so have little time to work on modules in my own time. I will however review patches posted here, and I will try do so fairly promptly. If you need this feature urgently, you can always contact me about paid work :)

Please read knowing that I appreciate your work on this module, and your attempts to help me solve "my" problem so far. I would gladly pay somebody something to help solve problems with contributed Drupal modules like this if I thought that I was going to get precise help with sufficient software engineering accuracy and instructions, and a result. The way you have tried so far to save time by not taking enough time to do that in attending to this support request (or perhaps bug) would not encourage me to do so yet with you. I recommend that you take a little bit more time to place your help remarks into a precise software engineering context, and you might find that it takes less time for everybody long term (and that is general advice for every single maintainer of a Drupal module).

Dr Darren Kelly (Webel IT Australia)

webel’s picture

I went back to Views 6.x-2.8 on an identical yet local install and it did not change anything concerning this problem, the served page still shows only one reference of many formatting using NodeReferenceViews 6.x-1.2 + CCK 6.x-2.6 + Views 6.x-2.8.

When I change the display setting for field_defining_document of my custom type Methodology from View to Title (link) the serves page shows the multiple referenced node links correctly.

webel’s picture

Category: bug » support

@joachim

The project page (there is no other documentation) states correctly:

The first view argument must be a node id, set to allow multiple ids.

This has passed to it all the nids from the CCK nodereference field.

No other arguments are passed to the view.

The view's default display is shown.

The example view to be cloned field_noderef_example has as far as I tell by default Allow multiple terms per argument TRUE (checked). It was not checked in the particular view I featured in this initial support request (as exported and included above), and I have no idea why. I (re)set it to true, and with the original version of this module restored it worked.

You can see it working live here: http://ppi.webel.com.au/node/2662

It had nothing at all to do with any single other part of any other posting within this issue. I had written:

I have correctly followed instructions for how I am supposed to achieve it, and it is not working

Well, I can't now claim that is so, somehow, at some stage, I have changed that setting

I'm sorry joachim that this has wasted your time too, however I promise I read the instructions. My view was cloned and adapted from yours, and thus should have had Allow multiple terms per argument TRUE (checked) unless it had been changed.

I've even now gone to the trouble to check that if I cloned field_noderef_example it has by default Allow multiple terms per argument TRUE (checked) after saving. It does.

I have just checked all of my field_ views, and it seems every one except the one that I have reported here field_defining_document has
field_noderef_example it has by default Allow multiple terms per argument TRUE (checked).

I sincerely apologise, you could not have guessed to ask to check it, because there is no reason to expect that the cloned version would have that setting changed.

webel’s picture

Postscript

You may close this after reading. I stand fully by all (other) remarks I've made in this issue report, and I hope everybody on Drupal.org reads it some day.

Proposal: every single Drupal module should have a systematic, structured, set of options that developers may/should check as "pre-conditions", and this should be served on the project page for that module.

I don't mean just as sentences within documentation (which should of course be read and checked against), I mean that a systematic record of requirements for correct operation be introduced for every module, and that this becomes a fundamental part of the module systems and generated documentation (both online, and distributed with the modules, generated).

joachim’s picture

Category: bug » support
Status: Active » Closed (fixed)

> I mean that a systematic record of requirements for correct operation be introduced for every module

That already exists: http://api.drupal.org/api/function/hook_requirements

But in the case of something like this, it would be rather onerous to check every noderef field, check it's set to display views, and dig into the view to check every setting. hook_requirements is meant more for deep-level system stuff.

> I don't mean just as sentences within documentation (which should of course be read and checked against)

Feel free start a list of those on the documentation page. I will add to it in due course.

As for my precision, I was replying to your comments while in the middle of other things. You can get prompt support, if a little rushed, or it can sink to the bottom of my pile of stuff to do and I'll get round to it when I have a wet weekend.

webel’s picture

@joachim

As for my precision, I was replying to your comments while in the middle of other things. You can get prompt support, if a little rushed, or it can sink to the bottom of my pile of stuff to do and I'll get round to it when I have a wet weekend.

Fair enough. I had a bad week last week (had just come out of hospital), had lost a lot of time, am late on delivering my current drupal site (due largely to delays with problem in contributed modules), and thus under a lot of pressure, and I was clearly in a stinky mood and not seeing very clearly.

Thanks for the support you do give, and for your work on this and other Drupal modules.

Please close.

webel’s picture

PS I also realise now why the view I was using was wrong. Afterwards, while I was falling asleep, I suddenly remembered I had not cloned the provided example to create the culprit view, rather I had a complex legacy view that I did not wish to repeat, and I had cloned that (some months ago), and tried to imitate the correct form for the nodereferenceviews, and obviously I had missed the multiple arguments setting on nid.

webel’s picture

joachim wrote:

>That already exists: http://api.drupal.org/api/function/hook_requirements

A discussion of digitally controlled requirements tracing and generated requirements artifacts was commenced in the general forum: http://drupal.org/node/753556

giorgosk’s picture

I had the same exact issue
the comment from merlin #4 solved my problem
#756344: Unable to pass multiple NID values into an argument

I personally changed the validator to simple validator
but perhaps a numeric validator would work