The current export button uses an image with a hardcoded image path:

<a href="....">
           <img src="/sites/all/modules/views_data_export/images/csv.png" 
                   alt="Download CSV File" 
                   title="Download CSV File" height="14" width="36">
 </a>

That is hard for a themer to overwrite; you'd have to use jQuery to manipulate the dom directly.

It would be great if this was stylable instead with CSS. Instead of the imgage tag, you could use some inner divs and then set the background image using CSS.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv’s picture

Version: 7.x-3.x-dev » 6.x-2.0-beta5
Status: Needs review » Active

+1 ,
an alternative is to generate a link, like the following modules do:
- print: 'print this page', 'send this page'
- nodereference_url: 'create node'
They support a link with only title, or include an icon, too.

nagy.balint’s picture

Version: 6.x-2.0-beta5 » 7.x-3.x-dev
FileSize
6.28 KB

I've made this patch to solve this issue for version 7.x-3.x-dev.

After you apply this patch the export links will only contain the Attach text, not an image, and the new css file will provide the proper background and will hide the Attach text from the link. Also i added a shared option which lets you select whether to have the image or just simple text link (basically the link gets a different class).

nagy.balint’s picture

Status: Active » Needs review

changed status.

johnv’s picture

Version: 6.x-2.0-beta5 » 7.x-3.x-dev
Status: Active » Needs work
FileSize
13.59 KB

Hi Bálint, I tested your patch, I like it, and I have the following comments:

- there is no need to put the css-file in a separate directory.

- the new setting is now under the FORMAT section. IMO this sets the file settings; it would be better to put it under DATA EXPORT SETTINGS, in the list "Path:, Attach to:, Batched export:"

- the default layout is now out-of-style. It would be nice if one could choose for one of both standard options:
-- action-link (like admin/content/node )
-- inline-link (like print moduleprint module )
See attached printscreen.

nagy.balint’s picture

Assigned: Unassigned » nagy.balint
Status: Needs work » Needs review
FileSize
7.52 KB

Sorry for the time it took me to get back to this.

I updated my patch to the latest dev, and reworked it according to your feedback, except your last point.

Im not sure how i could change the html structure of the feed_icon part of the template around the links, without overwriting the whole views-view.tpl template which is in the views module.

I attached the updated patch.

emorency’s picture

We export our views with Features. When I export the vies after applying the patch #5, I don't have the attribute 'link_only' so I have an error when reimporting my views... Would it be possible to have a default behavior to show only icons if the attribute is not found ?

In plugins/views_data_export_plugin_style_export.inc, change the line to this:

   'link_only' => isset($this->display->display_options['link_only']) ? $this->display->display_options['link_only'] : FALSE;

The last submitted patch, styleable_export_links-1379672-5.patch, failed testing.

abhi.sharma’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: styleable_export_links-1379672-5.patch, failed testing.

The last submitted patch, 5: styleable_export_links-1379672-5.patch, failed testing.

brandy.brown’s picture

Issue summary: View changes

I don't understand why there is a hard-coded image associated by default anyway ... ??? If a person wants an image, they can css a background image.

pancho29’s picture

I've rerolled the patch for 7.x-3.0-beta8.

lolandese’s picture

FileSize
2.81 KB

I get some errors when trying to apply the #12 patch. Can you have a look what I am doing wrong? See attachment for my terminal output.

Thanks.

darvanen’s picture

Status: Needs work » Needs review

I'm not familiar enough with git patching to help you but it did work for me using 'patch -p1 < filename' against the 7.x-3.x branch.

No errors with the patch that I can see.

Status: Needs review » Needs work

The last submitted patch, 12: views_data_export-styleable_export_links-1379672-12.patch, failed testing.

rooby’s picture

Assigned: nagy.balint » Unassigned
Status: Needs work » Needs review
FileSize
7.65 KB

Here is the exact patch from #12 rerolled to apply cleanly to latest dev version.

Also I'm guessing this is no longer assigned to nagy.balint since that was 3 years ago, so unassigning.

rooby’s picture

Patch works fine for me.
I had a quick look over the code and there are no obvious coding standards issues but I haven't reviewed it technically.

Sborsody’s picture

Status: Needs review » Needs work

The only issue I ran into after applying this patch was an undefined index error when looking at the view. Basically the "link only" setting isn't set until after explicitly setting it and re-saving the view.

Notice: Undefined index: link_only in attach_to() (line 176 of /export/www/html/sites/all/modules/contrib/views_data_export/plugins/views_data_export_plugin_style_export.inc).

Notice: Undefined property: views_display::$handler in execute() (line 1134 of /export/www/html/sites/all/modules/contrib/views/includes/view.inc).
Sneakyvv’s picture

Status: Needs work » Needs review
FileSize
8.65 KB

When you attach two (or more) views_data_export displays to one page display, it's impossible to make a distinction between them (except by the title attribute on the XLS-icon). So, I've expanded the patch from #16 to make it possible to add extra CSS classes to the link which allows to distinct the links or simply allows to add styling to them.
I also fixed the issue Sborsody described.

PhilY’s picture

Hello,

In release 7.x-3.0-beta8, the feed icon link is fully themable as indicated in theme/views_data_export.theme.inc file (lines 22 to 50).

For example, to change all XLS export icon:

function MYTHEME_views_data_export_feed_icon__xls($variables) {
  extract($variables, EXTR_SKIP);
  $image_path = '/path/to/the/xls/icon.png'; // INDICATE HERE THE PATH TO THE IMAGE FILE
  $image_class = 'icon-xls'; // INDICATE HERE THE CSS CLASS(ES) TO PUT ON THE IMAGE
  $url_options = array('html' => TRUE);
  if ($query) {
    $url_options['query'] = $query;
  }
  $image = theme('image', array('path' => $image_path, 'alt' => $text, 'title' => $text, 'attributes' => array('class' => $image_class))); // FUNCTION ALTERED TO ADD CUSTOM CSS CLASS TO THE IMAGE
  return l($image, $url, $url_options);
}

in which $image_path and $image_class variables were added and $image variable is altered to use added variables.

andileco’s picture

The last patch in the related issue that I added does the same thing as this patch, but approaches it in another way...perhaps a simpler way? Please check it out.

Steven Jones’s picture

Status: Needs review » Needs work

I prefer this patch and approach to the one in: #2261167: Option for non-image link display, I wonder if we couldn't just reduce it down to sending some classes to the theme function though, singling out a specific option for making the link use the 'default icon' or something, which just adds a class to the set of classes to add.

Happy to work on this in bit, unless someone else wants to pick it up.

andileco’s picture

Hey @Steven Jones--one of the things I liked about the other patch is that the alt text (which became the text displayed within the button/link) and the class options were both in the same location, so a site builder would only need to go to one place to do everything related to this. If you work on this patch, could you try to incorporate that same idea? Last time I tried this patch, it seemed less user-friendly in that way, so I continued to work on the other patch.

Steven Jones’s picture

Issue tags: +ComputerMinds
Vali Hutchison’s picture

Any update on this one - seems to have ground to a halt, likewise for #2261167: Option for non-image link display

capysara’s picture

Patch #19 works for me.

Rafal Lukawiecki’s picture

Patch #19 works for me. It would be nice to have it committed.

legato made their first commit to this issue’s fork.

legato’s picture

CSS classes must be added as array elements, not as a concatenated string.

  $url_options['attributes']['class'] = [$class_name];

  if ($css_class_icon) {
    $url_options['attributes']['class'][] = $css_class_icon;
  }
anoopsingh92’s picture

Hi,

I am assigning this issue to me. Let me try once to fix that. I will update you soon as I can fix it or not.

Thanks

anoopsingh92’s picture

Assigned: Unassigned » anoopsingh92
anoopsingh92’s picture

Hello @legato, I tried to apply both files of your patch but both are not applying to me.
Getting this error.

Lenovo@LAPTOP-PDE747K8 MINGW64 /c/xampp/htdocs/drupal-9/web/modules/contrib/views_data_export-1379672 (1379672-export-button-make)
$git apply -v views_data_export-styleable_export_links-1379672_0.patch
error: corrupt patch at line 120

Lenovo@LAPTOP-PDE747K8 MINGW64 /c/xampp/htdocs/drupal-9/web/modules/contrib/views_data_export-1379672 (1379672-export-button-make)
$ git apply -v views_data_export-styleable_export_links-1379672-19.patch
Checking patch plugins/views_data_export_plugin_display_export.inc...
Checking patch plugins/views_data_export_plugin_style_export.inc...
Checking patch theme/views_data_export.theme.inc...
error: while searching for:
 */
function theme_views_data_export_feed_icon($variables) {
  extract($variables, EXTR_SKIP);
  $url_options = array('html' => TRUE);
  if ($query) {
    $url_options['query'] = $query;
  }
  $image = theme('image', array('path' => $image_path, 'alt' => $text, 'title' => $text));
  return l($image, $url, $url_options);
}

/**

error: patch failed: theme/views_data_export.theme.inc:41
error: theme/views_data_export.theme.inc: patch does not apply
Checking patch views_data_export.css...
Checking patch views_data_export.module...
Checking patch views_data_export.views.inc...

Can you please suggest how to fix that issue?
Thanks

anoopsingh92’s picture

Assigned: anoopsingh92 » Unassigned

Need work