Download & Extend

Pass view object as argument to get_exposed_filter_output()

Project:Exposed Filter Data
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

As it works right now, get_exposed_filter_output() calls theme('exposed_filter_data'), so exposed_filter_data_preprocess_exposed_filter_data() runs. This checks if $vars['view'] is set, and if not, calls views_get_current_view() to get the current view.

This could be improved in a couple ways:

  • As far as I can tell, $vars['view'] is never set, if get_exposed_filter_output() is called. If a developer calls theme('exposed_filter_data') and passes a view object as the second argument, it will be set, but not when using the recommended get_exposed_filter_output()
  • If no view object is passed when calling theme('exposed_filter_data'), the view object will not be available in exposed_filter_data.tpl.php: the view is loaded by calling views_get_current_view(), but it's not put back into the $vars array. The template file included with the module doesn't try to use $view, but developers who override that template (for example, me) may want to.

I see a couple quick and easy changes that will improve the developer experience:

  • Accept a view object as an argument to get_exposed_filter_output() and pass through to theme('exposed_filter_data'). This way, when calling get_exposed_filter_output() in some preprocess function or template file, the developer can specify the view object to use.
  • If the view object is not passed in, save it back into the $vars array after calling views_get_current_view() to retrieve it, so that it's available to the template file.

Patch forthcoming.

Comments

#1

Status:active» needs review

Patch attached. The original issue report explains what it does.

AttachmentSize
1359332-1.patch 1.04 KB