I'm not sure exactly where to post this.

There are just some Views that cannot be produced all in one screen. And sometimes you need to export those views. When using Views Field View, and running a TXT export, you'll get LOTS of unwanted extra space.

The space comes after Views Field View sends data and Views Data Export tries to clean out the HTML tags.

TXT export also gives unwanted header labels, which appear as "[]" even when you are not using field labels in your view.

The following programming replaces "..\views-data-export\theme\views-data-export-txt-body.tpl.php" to eliminate white space, and only show field labels when requested.


<?php
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $rows: An array of row items. Each row is an array of content
 *   keyed by field ID.
 * - $header: an array of headers(labels) for fields.
 * - $themed_rows: a array of rows with themed fields.
 * @ingroup views_templates
 */

foreach ($themed_rows as $count => $row):
  foreach ($row as $field => $content):
?>
<?php if ($header[$field]): ?>
<?php print '[' . $header[$field] . ']'; ?>
<?php endif; ?>

<?php

  // Eliminates all HTML tags from output...
  $content = strip_tags($content);
  // Splits the array along line breaks...
  $results = array();
  $results = explode("\n",$content);
  // Loops through the content array...
  foreach ($results as $value) {
    // Removes extraneous space from the data...
    $value = trim($value, " \t\r\n");
    // Checks if data exist after the removal...
    if (strlen($value) > 0) {
      // Prints a result if it exists...
      print $value . "\r\n";
    }
  }
  // Erases unwanted connection to data...
  unset($value);

?>

<?php endforeach; ?>

<?php if ($header[$field]): ?>
<?php print '----------------------------------------'; ?>
<?php endif; ?>

<?php endforeach;

Comments

DrupalWoody created an issue. See original summary.

DrupalWoody’s picture

Status: Active » Patch (to be ported)
DrupalWoody’s picture

Issue summary: View changes
DrupalWoody’s picture

Issue summary: View changes
steven jones’s picture

Status: Patch (to be ported) » Closed (won't fix)

Sorry for the lack of attention to your issue, please accept my apologies.

Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.

As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.

If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.

Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)