1

I want the XLS/CSV export link buttons of an admin view to be displayed on top of that view. If it weren't a admin view I'ld simply put a slightly changed views-view--NAMEOFMYVIEW.tpl.php into my default theme's template folder. But now I'ld have to put that template inside the core's themes folder to work on that certain view since this view has an admin path and is themed by a core theme.

I don't want to add anything custom to the core. Is there another way to bring that button to the top?

2

You can create

function MODULE_preprocess_views_view_NAMEOFMYVIEW(&$variables) {
  $variables['title_suffix'] = array(
    /* Renderable data or just string instead of array */
  );
}

it will render you content between view title and view content.

1

you can also add the feed icon in the views header:

function MODULE_preprocess_views_view(&$vars) {
  if($vars['name'] == 'view_name') {
    $vars['header'] = $vars['feed_icon'];
  }
}
1

Thanks @mr1rk! Was a little bit difficult to get the MODULE_preprocess_views_view__NAMEOFMYVIEW to work. Fore more informations about that read: Specific preprocess functions for theme hook suggestions are not invoked in D7. Finally did it like that:

function MODULE_preprocess_views_view(&$vars) {
  $function_name = 'MODULE_preprocess_views_view__' . $vars['view']->name;
  if (function_exists($function_name)) {
    $function_name($vars);
  }
}

function MODULE_preprocess_views_view__NAMEOFMYVIEW(&$vars) {
  $vars['title_suffix'] = '<div style="float: right;">' . $vars['feed_icon'] . '</div>';
}
0

Right click your data export button. In my case XLS and select Inspect Element.

  1. Collapse the <div class="feed-icon"></div>, right click and select Copy.
  2. Paste the code inside your page.tpl.php file inside your theme.
  • Bad idea, since it was a core theme and I didn't want to do anything in core. – leymannx Aug 18 '15 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.