Hello, first I'll explain what I want to do.

I have a node-type with imagefield on it. When these node are made they will have multiple images attached to them. I would like the images for each node to be displayed in a block generated by views. The block should only display images from the node that is being displayed.

Currently, I am only able to get all images from all nodes of the same type to display. This is of course problematic, since it is pointless to display images from other nodes.

Essentially, I feel that I am missing something that should allow me to filter a view by the node that the user is viewing. Perhaps some sort of custom argument?

If anyone has any suggestions, it would be greatly appreciated. My view export is below

  $view = new stdClass();
  $view->name = 'test';
  $view->description = '';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'scenes/$arg/images';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = '';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'table';
  $view->nodes_per_block = '100';
  $view->block_more = FALSE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node_data_field_scene_image_1',
      'field' => 'field_scene_image_1_fid',
      'label' => '',
      'handler' => 'content_views_field_handler_group',
      'options' => 'thickbox][scene_preview',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'scene_review',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node_data_field_scene_image_1, node);
  $views[$view->name] = $view;

Comments

merlinofchaos’s picture

Status: Active » Fixed

There is a snippet in the Views snippets section that will tell you how to add code to the PHP Argument Code to get the nid of the node that is currently being viewed. You can tailor your view from that. You can find the snippets section by visiting http://drupal.org/handbook/modules/views

Kirk’s picture

Thanks for the tip. I'm not sure if this is what you were referring to but it worked for me. http://drupal.org/node/131547

For anyone else who might need to do this... This snippet EXCLUDES the current node, so all you have to do is leave the option set to "equal" and it works like a charm.

ressa’s picture

What can I say, but Thank You Guys! I needed to do exactly the same, and following the tips I had it working in 5 minutes. Drupal and its community truly rules.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

bergco’s picture

I'm sorry, but I really don't understand which option I have to set to 'equal'. I can see the image on every node now, except the one that it's attached to...

Drupal 6.13

bergco’s picture

Status: Closed (fixed) » Active
bergco’s picture

Got some things mixed up, it's working now.

bergco’s picture

Status: Active » Closed (fixed)