They have the relationship names appended to the beginning. Minor annoyance for me, major annoyance for some people that like to annoy me. Patch below that copies the parent get_field_labels and comments the part that adds the relationship name. In /views_data_export/plugins.

--- ./views_data_export_plugin_display_export.inc.orig  2015-03-24 08:47:08.602105000 -0400
+++ ./views_data_export_plugin_display_export.inc       2015-03-23 17:46:58.884754000 -0400
@@ -803,6 +803,48 @@
     return $conn_info['default']['driver'];
   }

+  function get_field_labels() {
+    // Use func_get_arg so the function signature isn't amended
+    // but we can still pass TRUE into the function to filter
+    // by groupable handlers.
+    $args = func_get_args();
+    $groupable_only = isset($args[0]) ? $args[0] : FALSE;
+
+    $options = array();
+    foreach ($this->get_handlers('relationship') as $relationship => $handler) {
+      if ($label = $handler->label()) {
+        $relationships[$relationship] = $label;
+      }
+      else {
+        $relationships[$relationship] = $handler->ui_name();
+      }
+    }
+
+
+    foreach ($this->get_handlers('field') as $id => $handler) {
+      if ($groupable_only && !$handler->use_string_group_by()) {
+        // Continue to next handler if it's not groupable.
+        continue;
+      }
+      if ($label = $handler->label()) {
+        $options[$id] = $label;
+      }
+      else {
+        $options[$id] = $handler->ui_name();
+      }
+/*
+      if (!empty($handler->options['relationship']) && !empty($relationships[$handler->options['relationship']])) {
+        $options[$id] = '(' . $relationships[$handler->options['relationship']] . ') ' . $options[$id];
+      }
+*/
+    }
+
+    return $options;
+  }
+
+
+
+
 }

 class views_data_export_plugin_query_default_batched extends views_plugin_query_default {
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davery’s picture

I'm making another small change. The labels for excluded fields were showing up in exports, so the data rows would be offset from the correct columns. This fixes that.

--- ./views_data_export_plugin_display_export.inc.orig  2015-03-24 08:47:08.602105000 -0400
+++ ./views_data_export_plugin_display_export.inc       2015-03-25 11:37:28.949836000 -0400
@@ -803,6 +803,52 @@
     return $conn_info['default']['driver'];
   }

+  function get_field_labels() {
+    // Use func_get_arg so the function signature isn't amended
+    // but we can still pass TRUE into the function to filter
+    // by groupable handlers.
+    $args = func_get_args();
+    $groupable_only = isset($args[0]) ? $args[0] : FALSE;
+
+    $options = array();
+    foreach ($this->get_handlers('relationship') as $relationship => $handler) {
+      if ($label = $handler->label()) {
+        $relationships[$relationship] = $label;
+      }
+      else {
+        $relationships[$relationship] = $handler->ui_name();
+      }
+    }
+
+
+    foreach ($this->get_handlers('field') as $id => $handler) {
+       if($handler->options['exclude'])
+       {
+               continue;
+       }
+      if ($groupable_only && !$handler->use_string_group_by()) {
+        // Continue to next handler if it's not groupable.
+        continue;
+      }
+      if ($label = $handler->label()) {
+        $options[$id] = $label;
+      }
+      else {
+        $options[$id] = $handler->ui_name();
+      }
+/*
+      if (!empty($handler->options['relationship']) && !empty($relationships[$handler->options['relationship']])) {
+        $options[$id] = '(' . $relationships[$handler->options['relationship']] . ') ' . $options[$id];
+      }
+*/
+    }
+
+    return $options;
+  }
+
+
+
+
 }

 class views_data_export_plugin_query_default_batched extends views_plugin_query_default {
agn507’s picture

I ran into this same issue today and resolved it by adding

$tag = preg_replace("/\([^)]+\)/","",$tag);

as the first line in the clean_xml_tag function.

This just simply changed a related field label from

(Products referenced by commerce_product) product id
to
product id

ayalon’s picture

It's an annoying bug. Added a patch and hope it wil be soon merged.

imclean’s picture

There are 2 separate issues here:

  1. Labels of excluded fields are not excluded
  2. The relationship name is prepended to the label of the relevant fields

This is more than a minor annoyance, it makes it unusable for anything more than the simplest of views.

imclean’s picture

Priority: Minor » Normal
imclean’s picture

imclean’s picture

Status: Active » Needs review

The last submitted patch, 3: views_data_export_header-2458357.patch, failed testing.

The last submitted patch, 3: views_data_export_header-2458357.patch, failed testing.