When I attach the Data Export in Views, The icon displays in the buttom of the page, how can I put that feed XLS icon on top and/or design it ?

Comments

PhilY’s picture

That would be great to be able to choose to put the icon either on top or bottom of the attached display...

So far, as I'm using jsInjector module on my website, I'm using a small jQuery code to move the icon above the view :

jQuery(function($){
	$('div.feed-icon').insertBefore($('div.view-xxxxxxxxxxxxx'));
}); //jQuery

in which "xxxxxxxxxxxxx" should be replaced by the view machine name.

magnetive’s picture

Issue summary: View changes

You can override the Views Theme. Then you can put the Icon ("feed-icon") on top.

PhilY’s picture

Thanks, would you mind providing an example?
I'm a beginner in theme template overriding ;-)

5t4rdu5t’s picture

If you want to display the icon on both top and bottom of your "Page" display you can easily do it by adding a Global: PHP field to your view's header with the following code:

print $view->feed_icon;

Make sure your "Data export" display is attached to your "Page" display.

zarabatana’s picture

Solution in #1 worked for me.
Thanks.

pjbarry21’s picture

#1 also worked for me. Thanks!

rooby’s picture

Version: 7.x-3.0-beta6 » 7.x-3.x-dev
Status: Active » Fixed

The solution in #1 is not ideal because it is unnecessary javascript (and if you aren't already using that module for something else an unnecessary module) and it won't work for users without javascript.

I would also consider your selector 'div.feed-icon' to be too generic and is at risk of acting on markup you don't intend.

The solution in #4 is not ideal because entering PHP into the database like that is not a good idea. For more information on why see this informative stack exchange post.
Having the PHP module enabled at all is also somewhat of a security risk.

The best solution is #2, although that comment doesn't give information on how to do that.

So how you would do that is override the template for the view. This blog post has some more information on overriding views templates (I am in no way affiliated with that website).

So basically this:

  1. Copy the views-view.tpl.phph file from views into your theme (or its templates directory if it has one). Note that you can rename the file in certain ways to make it specific to an individual view or display. The "Theme: Information" section of the views UI will give you more information. Also see the blog post for more information on that.
  2. Clear the cache so the site starts using your new template file instead of the default views one. The "Theme: Information" part of the views UI should now indicate that your file is being used.
  3. In your theme's version of the template file move the feed icon section wherever you want it. Potentially you would put it under the exposed filters or something. Currently the the feed icon part of the template looks like this (move this whole section):
      <?php if ($feed_icon): ?>
        <div class="feed-icon">
          <?php print $feed_icon; ?>
        </div>
      <?php endif; ?>
    

Status: Fixed » Closed (fixed)

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

gabrielZ’s picture

Solution #7 Worked for me. Thank you.

markusd1984’s picture

brilliant thanks for sharing, would be great to theme a button with text, ideally with hover effect instead of a static image.