I had a look about adding a filter handler add getting it exposed. Unfortunately it looks like the whole "exposing" feature is still TODO.
Anyway, I started adding a filter handler called "views_handler_filter_list_options" - which is targeted for "list" values like the node type. It supports multiple / not multiple value forms and different value form styles (select vs checkboxes/radios).
To get the exposed filters at least working I tried to a initial version of render_filters() for display plugins, but I failed. I just called drupal_get_form() there to get the filter form, but the problem I encountered is that the view is already built and executed at this stage. I don't know how you have planned to do this? I was also not sure how the handler forms should be separated.
I wasn't sure where I should put some things, so I just added the views_view_form() to render exposed filters/styles at the bottom of view.inc. Also I added some operator definitions views_handler_operator_eqneq() from 1.x to handlers.inc.
As I'm completely unsure how you planned to get the exposed stuff working I'm stopping here.. Hopefully it's a good start, at least views_handler_filter_list_options() should be useful.
I've used this view + hack to test the exposed node type filter:
$view = new view; $view->name = 'views_node_type'; $view->set_page_size(50); //display options $display = new views_display; $display->display_plugin = 'embed'; $display->style_plugin = 'default'; $display->id = 'embed'; $view->display[] = $display; //defining the fields to display $field = new views_field; $field->tablename = 'node'; $field->field = 'title'; $field->display_id = 'page'; $field->options['link_to_node'] = TRUE; $view->field[] = drupal_clone($field); $field->field = 'created'; $view->field[] = drupal_clone($field); $field->tablename = 'users'; $field->field = 'name'; $field->options['link_to_user'] = TRUE; $view->field[] = $field; //sorting after node creation time $sort = new views_sort; $sort->tablename = 'node'; $sort->field = 'created'; $sort->order = 'ASC'; $view->sort[] = $sort; $filter = new views_filter; $filter->tablename = 'node'; $filter->field = 'type'; $filter->operator = isset($_POST['operator']) ? $_POST['operator'] : '='; $filter->value = isset($_POST['value']) ? $_POST['value'] : 'page'; $filter->exposed = 1; $filter->options['style'] = 'select'; $filter->options['multiple'] = TRUE; $view->filter[] = $filter; //build, execute and render view $view->args = array($type); $view->build(); $view->execute(); $output .= $view->render(); return $output;
Comment | File | Size | Author |
---|---|---|---|
views2_exposed_filters.patch | 8.27 KB | fago | |
Comments
Comment #1
fagoah I forgot one thing regarding "//TODO: check & cleanup (multiple vs not) value data"
For this filter handler it should be enforced that users have to update their value_form settings, if they change the filter to be/be not multiple. If this won't be allowed by the UI, the query() method needs to check for this case and cut off additional values when multiple == FALSE.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThis doesn't really apply anymore. It didn't quite match my vision of how the whole system should work, anyhow.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.