I think my need is simple but after a whole lot of search i am unable to get it working - hence this post

i have one cck with book name, book author, Book number, book publisher, book references etc ( and some more fields);

Next i have another cck called bookreading_schedule with two fields - one date and another (a node reference) to the above book name.

Now I want a view (based on node: 'bookreading_schedule') which lists the date and with the date lists its referred book name AND ALSO book author and book number (these four fields)
Through node reference i got the book name to show up in the view next to the relevant date.
but how do i get the selected fields (about the book) to show up.

So, How do i get only the selected fields from the referred node to show up in views in tabular form
thanks
geniekids

Comments

dtabach’s picture

Durval Tabach

ratnesh aarohi’s picture

Read the link in detail - but that isn't want i am looking for - (atleast how i have understood)

What i am looking for is how - in VIEWS - do i get to see other fields of the referenced node apart fromt he referenced field.

Currently in my view - i have two fields
1. first is the scheduled date
2. Next to the date is the referenced filed - book name (this can be shown as a link or plain text or as a full node).

What i want is not to only see the book title (which i am already seeing) nor to see the full node - but in a table view - see to the right of book_name few (selected) fields from the librarybook_node

i am stuck as to how to get this view
My final view (in table form) should look like this:

bookreading_Date ||| Book_Name ||| book_author ||| book_number
1-aug-08 ||| Titanic ||| Mr x ||| A-63
2-aug-08 ||| Whales ||| Ms Y ||| A-88

.....and so on

Here obviously the bookreading_date and Book_name (as node reference field) is stored in the node type Bookreading _schedule, the the other two fields are obtained from the Librarybook node

The question sis how to get these other two fields apart from the first two

i hope i have explained this i detail

ratnesh

ratnesh aarohi’s picture

Waitign for somebody to guide me - please!

OneTwoTait’s picture

I'm searching for how to do this too... I'll post here if I find it. Anybody else know?

In my case node-type1 references node-type2. node-type2 contains an image field but I want to be able to display that image filed in node-type1.

glennnz’s picture

I'm trying to show images from referenced nodes as well, please post links to any solutions here.

Thanks

Glenn

Glenn
THECA Group

theusualsuspect’s picture

i am looking to accomplish this too.. exactly what is described above. But how to?

theusualsuspect’s picture

This solution is for Drupal 6 with Views 2..

(Views 2 is simply the most amazing module ever made for Drupal. It accomplishes so many things, once you understand it).

Anyways the initial problem was: How can I retrieve the fields from a referenced node in my view? When selecting the reference from your add field list, you are left with four option to select from: Title (with link), Title (no link), full node and teaser text. But what if you want to retrieve only specific CCK fields from the referenced node?

The solution: Add a relationship.

You first add a relationship and select the content->reference field. You optionally might set this required. Once this is set, you can go back to your fields and select whatever CCK field you want to retrieve. In the formular to follow, you'll find a list where you can specify a reference. Select the reference you created before. This ensures that the CCK field you add only comes from the node reference you set before as a relationship.

I hope this helps people who are directed to this forum message. Au revoir.

glennnz’s picture

@usualsuspect

Couldn't get this to work, would you please export your view and put it here?

Thanks

Glenn

Glenn
THECA Group

theusualsuspect’s picture

$view = new view;
$view->name = 'nodequeue_9';
$view->description = 'Display a list of all nodes in queue \'Lesenswert Block\'';
$view->tag = 'nodequeue';
$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', 'Standards', 'default');
$handler->override_option('relationships', array(
  'nodequeue_rel' => array(
    'id' => 'nodequeue_rel',
    'table' => 'node',
    'field' => 'nodequeue_rel',
    'label' => 'queue',
    'required' => 1,
    'limit' => TRUE,
    'qids' => array(
      '9' => '9',
    ),
    'relationship' => 'none',
  ),
  'field_reference_nid' => array(
    'id' => 'field_reference_nid',
    'table' => 'node_data_field_reference',
    'field' => 'field_reference_nid',
  ),
));
$handler->override_option('fields', array(
  'body' => array(
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
  ),
));
$handler->override_option('sorts', array(
  'position' => array(
    'id' => 'position',
    'table' => 'nodequeue_nodes',
    'field' => 'position',
    'order' => 'ASC',
    'relationship' => 'nodequeue_rel',
  ),
));
$handler->override_option('filters', array(
  'status_extra' => array(
    'id' => 'status_extra',
    'table' => 'node',
    'field' => 'status_extra',
    'operator' => '=',
    'value' => '',
    'group' => 0,
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'relationship' => 'none',
  ),
  'type' => array(
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'Queue \'Lesenswert Block\'');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('use_pager', '1');
$handler->override_option('use_more', 1);
$handler->override_option('use_more_text', 'Weiter');
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'teaser' => 1,
  'links' => 1,
));
$handler = $view->new_display('page', 'Seite Lesenswert', 'page');
$handler->override_option('relationships', array(
  'field_reference_nid' => array(
    'label' => 'Referenz',
    'required' => 1,
    'delta' => -1,
    'id' => 'field_reference_nid',
    'table' => 'node_data_field_reference',
    'field' => 'field_reference_nid',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'body' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
  'field_reference_nid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => 'aus [field_reference_nid]',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_reference_nid',
    'table' => 'node_data_field_reference',
    'field' => 'field_reference_nid',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
  'name' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => 'von [name]',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'field_reference_nid',
  ),
));
$handler->override_option('sorts', array());
$handler->override_option('filters', array(
  'status_extra' => array(
    'id' => 'status_extra',
    'table' => 'node',
    'field' => 'status_extra',
    'operator' => '=',
    'value' => '',
    'group' => 0,
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'quotation' => 'quotation',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('title', 'Lesenswert');
$handler->override_option('row_plugin', 'fields');
$handler->override_option('row_options', array(
  'inline' => array(
    'field_reference_nid' => 'field_reference_nid',
    'name' => 'name',
  ),
  'separator' => '',
));
$handler->override_option('path', 'lesenswert');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('relationships', array(
  'nodequeue_rel' => array(
    'id' => 'nodequeue_rel',
    'table' => 'node',
    'field' => 'nodequeue_rel',
    'label' => 'queue',
    'required' => 1,
    'limit' => TRUE,
    'qids' => array(
      '9' => '9',
    ),
    'relationship' => 'none',
  ),
  'field_reference_nid' => array(
    'label' => 'Referenz',
    'required' => 1,
    'delta' => -1,
    'id' => 'field_reference_nid',
    'table' => 'node_data_field_reference',
    'field' => 'field_reference_nid',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'body' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'body',
    'table' => 'node_revisions',
    'field' => 'body',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
  'field_reference_nid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 1,
      'text' => 'aus [field_reference_nid]',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_reference_nid',
    'table' => 'node_data_field_reference',
    'field' => 'field_reference_nid',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'none',
  ),
  'name' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'override' => array(
      'button' => 'Standard verwenden',
    ),
    'relationship' => 'field_reference_nid',
  ),
));
$handler->override_option('filters', array(
  'status_extra' => array(
    'id' => 'status_extra',
    'table' => 'node',
    'field' => 'status_extra',
    'operator' => '=',
    'value' => '',
    'group' => 0,
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('title', 'Lesenswert');
$handler->override_option('use_ajax', FALSE);
$handler->override_option('items_per_page', 1);
$handler->override_option('use_pager', '0');
$handler->override_option('row_plugin', 'fields');
$handler->override_option('row_options', array(
  'inline' => array(
    'field_reference_nid' => 'field_reference_nid',
    'name' => 'name',
  ),
  'separator' => '',
));
$handler->override_option('block_description', 'Lesenswert Block');
$handler->override_option('block_caching', -1);

Unfortuantely, I don't get an emails when any forum I posted in is updated. So thats why I am late responding. If you still have any questions... shoot.

glennnz’s picture

Aaaaarrrrrrgh!

I still can't get this to work!!

Has anybody got this working?

Following theusualsuspect's comment, I added a relationship, removed arguments, and had my CCK field based on the relationship.

This displays nothing in my block.

Glenn

Glenn
THECA Group

Feet’s picture

I was looking to do this too.

I followed theusualsuspect's suggestion and it worked for me.

In case anybody is (as I was) wondering if it works.

Cheers.

Feet

dspring0021’s picture

glennnz, I know this is a very late reply, but did you ever get this resolved. I am at my wit's end trying to figure out how to display CCK fields of referenced nodes in my view. It's seems so obviously straightforward, but the data is not display for my CCK fields (only for the node-specific fields: title, type, nid, etc). I'm starting to wonder if it's a problem with clashing modules. Ugh!

jgrubb’s picture

I finally was able to make this work after about 5 hours of pulling my hair out over this extremely simple-seeming use case.

Relationship - The node_reference field. Require this relationship
Arguments - Nid , get NID from URL as default argument. this turned out to be the key bit.
Fields - I needed the body of the referenced node to show up in the referring node. Set to "Node: Body", and use the relationship above.

Filters - the other key bit. Filter on Node:type, the referring content type. I had this backwards and was filtering for the referenced content type.

Good luck.