Index: modules/node.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/node.views.inc,v
retrieving revision 1.91
diff -u -r1.91 node.views.inc
--- modules/node.views.inc	2 Dec 2008 22:17:41 -0000	1.91
+++ modules/node.views.inc	30 Jan 2009 12:14:04 -0000
@@ -663,7 +663,8 @@
 function template_preprocess_views_view_row_node(&$vars) {
   $options = $vars['options'];
   $vars['node'] = ''; // make sure var is defined.
-  $nid = $vars['row']->nid;
+  $alias = (isset($vars['view']->style_plugin->row_plugin->value_alias)) ? $vars['view']->style_plugin->row_plugin->value_alias : 'nid';
+  $nid = $vars['row']->{$alias};
   if (!is_numeric($nid)) {
     return;
   }
Index: modules/node/views_plugin_row_node_view.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/node/views_plugin_row_node_view.inc,v
retrieving revision 1.1
diff -u -r1.1 views_plugin_row_node_view.inc
--- modules/node/views_plugin_row_node_view.inc	3 Sep 2008 19:21:29 -0000	1.1
+++ modules/node/views_plugin_row_node_view.inc	30 Jan 2009 12:16:20 -0000
@@ -14,6 +14,7 @@
   function option_definition() {
     $options = parent::option_definition();
 
+    $options['relationship'] = array('default' => 'none');
     $options['teaser'] = array('default' => TRUE);
     $options['links'] = array('default' => TRUE);
     $options['comments'] = array('default' => FALSE);
@@ -22,6 +23,64 @@
   }
 
   function options_form(&$form, &$form_state) {
+
+    // Shamelessly stolen from views_ui_config_item_form()
+
+    $view = &$form_state['view'];
+    $display_id = $form_state['display_id'];
+
+    // A whole bunch of code to figure out what relationships are valid for
+    // this item.
+    $relationships = $view->display_handler->get_option('relationships');
+    $relationship_options = array();
+
+    foreach ($relationships as $relationship) {
+      $relationship_handler = views_get_handler($relationship['table'], $relationship['field'], 'relationship');
+
+      // If this relationship is valid for this type, add it to the list.
+      $data = views_fetch_data($relationship['table']);
+      $base = $data[$relationship['field']]['relationship']['base'];
+      // TODO : no $form_state['type']
+//      $base_fields = views_fetch_fields($base, $form_state['type']);
+//      $base_fields = views_fetch_fields($base, 'relationship');
+//      if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
+          $relationship_handler->init($view, $relationship);
+          $relationship_options[$relationship['id']] = $relationship_handler->label();
+//      }
+    }
+
+    if (!empty($relationship_options)) {
+      // Make sure the existing relationship is even valid. If not, force
+      // it to none.
+      // TODO : no $form_state['type']
+      //$base_fields = views_fetch_fields($view->base_table, $form_state['type']);
+      //if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
+          $relationship_options = array_merge(array('none' => t('Do not use a relationship')), $relationship_options);
+      //}
+      $rel = empty($this->options['relationship']) ? 'none' : $this->options['relationship'];
+      if (empty($relationship_options[$rel])) {
+        // Pick the first relationship.
+        $rel = key($relationship_options);
+        // We want this relationship option to get saved even if the user
+        // skips submitting the form.
+        // TODO: not sure exatcly what to do with this.
+        //$view->set_item_option($display_id, $type, $id, 'relationship', $rel);
+        //views_ui_cache_set($view);
+      }
+
+      $form['relationship'] = array(
+        '#type' => 'select',
+        '#title' => t('Relationship'),
+        '#options' => $relationship_options,
+        '#default_value' => $rel,
+      );
+    }
+    else {
+      $form['relationship'] = array(
+        '#type' => 'value',
+        '#value' => 'none',
+      );
+    }
     $form['teaser'] = array(
       '#type' => 'checkbox',
       '#title' => t('Display only teaser'),
@@ -38,4 +97,11 @@
       '#default_value' => $this->options['comments'],
     );
   }
+  function query() {
+    if (isset($this->options['relationship']) && isset($this->view->relationship[$this->options['relationship']])) {
+      $relationship = $this->view->relationship[$this->options['relationship']];
+      $this->value_alias = $this->view->query->add_field($relationship->alias, 'nid');
+    }
+    parent::query();
+  }
 }
Index: plugins/views_plugin_style.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/plugins/views_plugin_style.inc,v
retrieving revision 1.4
diff -u -r1.4 views_plugin_style.inc
--- plugins/views_plugin_style.inc	8 Oct 2008 00:14:01 -0000	1.4
+++ plugins/views_plugin_style.inc	30 Jan 2009 12:17:16 -0000
@@ -193,5 +193,12 @@
     }
     return $errors;
   }
+
+  function query() {
+    parent::query();
+    if (isset($this->row_plugin)) {
+      $this->row_plugin->query();
+    }
+  }
 }
 
