I'm trying to insert a code (a button) from a module to a specific place in a view (between the filters and the array). Does anyone have an idea of how it can be done ?


1 Answer 1


Copy sites/all/modules/views/theme/views-exposed-form.tpl.php into your theme's template folder. Rename it to views-exposed-form--YOURVIEWMACHINENAME.tpl.php and clear caches. You should be able to put your button after the exposed filter content.

  • It is what i did. I didn't make myself clear about the issue. I need the button to be shown <b>after</b> a serie of operations in the module. I've trying module_invoke but it doesn't seem to work.
    – Ismail H
    Commented Apr 20, 2015 at 8:21
  • Can you elaborate more on the "series of operations"? From what I gather, you have a View with exposed filters, the user fills out the filters, submits the form, and then you want your button to appear, before the results are shown?
    – ouni
    Commented Apr 22, 2015 at 0:08
  • The serie of operations consists of : Rendering the view, Rendering the correct exposed filters Put the correct defaut value in one of the filters Then the button appears
    – Ismail H
    Commented Apr 22, 2015 at 13:42
  • Thank you for trying @Zarathustra but I just gave up this option. Sorry for bohering you ! But if you have an answer i'll be more than pleased to hear it !
    – Ismail H
    Commented Apr 22, 2015 at 13:47
  • What you probably want is hook_form_views_exposed_form_alter(). Inside this function, add your button using the form API, and then use #attach to add a JavaScript file. In this file, you can use jQuery to hide the button on page load, and then make it reappear when other values on the form change. Another method is to use Form API #states, which may be able to handle the JavaScript part of it for you. Best of luck!
    – ouni
    Commented Apr 23, 2015 at 14:22

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