Hello,

Thank you for this module. It's very useful. I used this to add an export .csv button to a custom search using views exposed filters. The search and export work well, however, we do not wish to allow data export if all exposed filters are empty as this would show all the data in the database tables. Is it possible to hide the .csv button if all exposed filters are empty?

Mark

Comments

jvdurme’s picture

Just found how to do this. Edit your view and click on Theme:Information in the Style Settings box. Then you see "Display Output" at the top of the list and a few filenames after that. Click on "Display output" and copy and paste the php code you see there into a new file with the filename that is listed last after "Display output".
Place this file in your active theme directory.
Then click on the button "Rescan template files" in the view edit theme information section. That filename should now be in bold, meaning it's being used.
Views will now use that file to display the view and you can modify this to add an if clause for displaying the feed/csv icon, as show below in this code.
I just took a hard coded integer for all rows, but modify it to meet your demands. Or use another available variable as listed at the beginning of the code.

<?php
/**
 * @file views-view.tpl.php
 * Main view template
 *
 * Variables available:
 * - $classes_array: An array of classes determined in
 *   template_preprocess_views_view(). Default classes are:
 *     .view
 *     .view-[css_name]
 *     .view-id-[view_name]
 *     .view-display-id-[display_name]
 *     .view-dom-id-[dom_id]
 * - $classes: A string version of $classes_array for use in the class attribute
 * - $css_name: A css-safe version of the view name.
 * - $css_class: The user-specified classes names, if any
 * - $header: The view header
 * - $footer: The view footer
 * - $rows: The results of the view query, if any
 * - $empty: The empty text to display if the view is empty
 * - $pager: The pager next/prev links to display, if any
 * - $exposed: Exposed widget form/info to display
 * - $feed_icon: Feed icon to display, if any
 * - $more: A link to view more, if any
 * - $admin_links: A rendered list of administrative links
 * - $admin_links_raw: A list of administrative links suitable for theme('links')
 *
 * @ingroup views_templates
 */
?>
<div class="<?php print $classes; ?>">
  <?php if ($admin_links): ?>
    <div class="views-admin-links views-hide">
      <?php print $admin_links; ?>
    </div>
  <?php endif; ?>
  <?php if ($header): ?>
    <div class="view-header">
      <?php print $header; ?>
    </div>
  <?php endif; ?>

  <?php if ($exposed): ?>
    <div class="view-filters">
      <?php print $exposed; ?>
    </div>
  <?php endif; ?>

  <?php if ($attachment_before): ?>
    <div class="attachment attachment-before">
      <?php print $attachment_before; ?>
    </div>
  <?php endif; ?>

  <?php if ($rows): ?>
    <div class="view-content">
      <?php print $rows; ?>
    </div>
  <?php elseif ($empty): ?>
    <div class="view-empty">
      <?php print $empty; ?>
    </div>
  <?php endif; ?>

  <?php if ($pager): ?>
    <?php print $pager; ?>
  <?php endif; ?>

  <?php if ($attachment_after): ?>
    <div class="attachment attachment-after">
      <?php print $attachment_after; ?>
    </div>
  <?php endif; ?>

  <?php if ($more): ?>
    <?php print $more; ?>
  <?php endif; ?>

  <?php if ($footer): ?>
    <div class="view-footer">
      <?php print $footer; ?>
    </div>
  <?php endif; ?>

  <?php if ($feed_icon): ?>
              /**** added this if clause to control icon display, modify to your needs ****/
		<?php if ($view->total_rows < 63410): ?>
		    <div class="feed-icon">
  	    <?php print $feed_icon; ?>
  	  </div>
       /**** and added this extra endif ****/
  	<?php endif; ?>
  <?php endif; ?>

</div><?php /* class view */ ?>
steven jones’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.