Similar to #1021394: Hide apply button when no filters are shown I would like to hide the reset button if all the filters have been hidden by VFS. Unfortunately this is not so easy, because both use hook_form_FORMID_alter, but altering the module weight to be higher than VFS i managed to do it.

Files: 

Comments

snufkin’s picture

Status:Active» Needs review
StatusFileSize
new1.23 KB

Patch and install file (stupid CVS doesnt allow me to create a diff for new files if i dont have commit access).

<?php
/**
 * Implements hook_update_N().
 *
 * Alter the module weight so that it fires after views_filters_selective, thus
 * allowing us to hide the reset button if no filters are shown.
 */
function views_filters_reset_update_6001() {
 
$weight = db_result(db_query('SELECT weight FROM {system} WHERE name = "views_filters_selective"'));
  if (empty(
$weight)) {
   
$weight = 0;
  }
 
$ret = array();
 
$ret[] = update_sql('UPDATE {system} SET weight = %d WHERE name = "views_filters_reset"', $weight++);
  return
$ret;
}
?>
infojunkie’s picture

Status:Needs review» Fixed

Committed to the latest dev. Please try it 12 hours from now and let me know if it works for you.

roball’s picture

Nice functionality - that is also similar to what i tried in #913410: Only show Reset button when there is actually something to reset: Hide reset button when no filters have been used. maybe you can come up with a better approach?

roball’s picture

I have just updated to Views Hacks 6.x-1.x-dev (2011-Jan-11), and drush updb said

Executing views_filters_reset_update_6001                                                                                                                         [success]
UPDATE {system} SET weight = %d WHERE name = &quot;views_filters_reset&quot;                                                                                      [success]

Does this look correct?

snufkin’s picture

yes, the db update doesnt replace the arguments when it displays the query. I tested it and it worked just fine.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.