Hi!
I cannot resolve simple task and need help. May be I do something wrong.
I have node type 'event' and two node other types: 'event_page' and 'event_request'. Each of them has field 'event_ref' referrencing to event.
At 'event_page' and 'event_request' I need a block with list of event_pages which has the same value of event_ref as the current one has.
How to use value of cureent node field as contextual filter in view?
Comments
Here's my recipe:
// If we're on a node page... if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) { // Load the node. $node = node_load(arg(1)); // Check the key of the field using devel module. // dpm($node->field_event_ref[$node->langcode][0]); // Get and return the field value. $lang = $node->langcode; return $node->field_event_ref[$lang][0]['value']; }One thing to note is that if your
event_reffield is not a text field (if it's a reference field or a taxonomy field, for example) that final key will be something other than'value'.You can enable the devel module and use the dpm() function to check!