I'm using this module combined with views_customfield.
When I try to export to csv a view, I get all the values, except the ones created with views_customfield module, called Customfield: PHP code

I've tried to debug the process of exporting to cvs and it seems that only exports values that are stored in the database: only the values extracted from queries are shown in the cvs file.

The problem it is not the tpl file used to format the output, because if I print there the values of the array $data using var_export($data, TRUE), the field that I want it's not there.

If I use the views_bonus module, I get the php code customfields printing $output in the tpl file.

Comments

gabrielu’s picture

This issue is also present in the 7.x branch.

Any news about this?

gabrielu’s picture

Also see related issue. Not sure yet who is responsible http://drupal.org/node/1088776#comment-5213160

jvieille’s picture

Status: Active » Needs review

I got that module to work with Views Customfield
- with the stable release, just copy the customfield field token into a "Global text" field
- with the dev, you need to remove the pre-render() function and put its code in the render() function (changing $results by $values from the argument):

in views_customfield_handler_field_phpcode.inc

-  function pre_render($results) {
-    // Evaluate the PHP code.
-    foreach ($this->view->result as $i => $row) {
-      $this->view->result[$i]->{$this->field_alias} = $this->render_row($row);
-    }
-    
-    // If we're sorting, do the actual sorting then fix the results as per the pager info.
-    if ($this->options['sortable'] != VIEWS_CUSTOMFIELD_SORTABLE_NO && $this->sort_order) {
-      usort($this->view->result, array(new views_customfield_sorter($this->options['sortable'], $this->sort_order, $this->field_alias), 'sort'));
-
-      // Handle paging logic as in view::execute()
-      if (!empty($this->pager['items_per_page'])) {
-
-        if (!empty($this->pager['use_pager']) || !empty($this->view->get_total_rows)) {
-          $this->view->total_rows = count($this->view->result) - $this->pager['offset'];
-        }
-
-        if (!empty($this->pager['use_pager'])) {
-          // dump information about what we already know into the globals
-          global $pager_page_array, $pager_total, $pager_total_items;
-          // total rows in query
-          $pager_total_items[$this->pager['element']] = $this->view->total_rows;
-          // total pages
-          $pager_total[$this->pager['element']] = ceil($pager_total_items[$this->pager['element']] / $this->pager['items_per_page']);
-
-          // What page was requested
-          $pager_page_array = isset($_GET['page']) ? explode(',', $_GET['page']) : array();
-
-          // If the requested page was within range. $this->pager['current_page']
-          // defaults to 0 so we don't need to set it in an out-of-range condition.
-          if (!empty($pager_page_array[$this->pager['element']])) {
-            $page = intval($pager_page_array[$this->pager['element']]);
-            if ($page > 0 && $page < $pager_total[$this->pager['element']]) {
-              $this->pager['current_page'] = $page;
-            }
-          }
-          $pager_page_array[$this->pager['element']] = $this->pager['current_page'];
-        }
-
-        $offset = $this->pager['current_page'] * $this->pager['items_per_page'] + $this->pager['offset'];
-        $results = array_slice($this->view->result, $offset, $this->pager['items_per_page']);
-        $this->view->result = $results;
-      }
-      
-      $this->view->pager = $this->pager;
-    }
-  }

  function render($values) {
+    // Evaluate the PHP code.
+    foreach ($this->view->result as $i => $row) {
+      $this->view->result[$i]->{$this->field_alias} = $this->render_row($row);
+    }
+    
+    // If we're sorting, do the actual sorting then fix the results as per the pager info.
+    if ($this->options['sortable'] != VIEWS_CUSTOMFIELD_SORTABLE_NO && $this->sort_order) {
+      usort($this->view->result, array(new views_customfield_sorter($this->options['sortable'], $this->sort_order, $this->field_alias), 'sort'));
+
+      // Handle paging logic as in view::execute()
+      if (!empty($this->pager['items_per_page'])) {
+
+        if (!empty($this->pager['use_pager']) || !empty($this->view->get_total_rows)) {
+          $this->view->total_rows = count($this->view->result) - $this->pager['offset'];
+        }
+
+        if (!empty($this->pager['use_pager'])) {
+          // dump information about what we already know into the globals
+          global $pager_page_array, $pager_total, $pager_total_items;
+          // total rows in query
+          $pager_total_items[$this->pager['element']] = $this->view->total_rows;
+          // total pages
+          $pager_total[$this->pager['element']] = ceil($pager_total_items[$this->pager['element']] / $this->pager['items_per_page']);
+
+          // What page was requested
+          $pager_page_array = isset($_GET['page']) ? explode(',', $_GET['page']) : array();
+
+          // If the requested page was within range. $this->pager['current_page']
+          // defaults to 0 so we don't need to set it in an out-of-range condition.
+          if (!empty($pager_page_array[$this->pager['element']])) {
+            $page = intval($pager_page_array[$this->pager['element']]);
+            if ($page > 0 && $page < $pager_total[$this->pager['element']]) {
+              $this->pager['current_page'] = $page;
+            }
+          }
+          $pager_page_array[$this->pager['element']] = $this->pager['current_page'];
+        }
+
+        $offset = $this->pager['current_page'] * $this->pager['items_per_page'] + $this->pager['offset'];
+        $values= array_slice($this->view->result, $offset, $this->pager['items_per_page']);
+        $this->view->result = $values;
+      }
+      
+      $this->view->pager = $this->pager;
+    }
    return $values->{$this->field_alias};
  }
greggadsdon’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

As Drupal 6 nears the end of its life and support period, the 6.x version of Views Data Export will not be supported either. To that end, this issue has been closed, and will not be resolved in the 6.x branch of Views Data Export.

If this issue is still relevant to 7.x branch of Views Data Export, then please re-open and move to a relevant 7.x version.