Hi Wim,

After a recent update to HS or possibly to drupal, HS no longer works in my themed exposed view. I'm using the solution outlined here - in which template.php issues drupal_render($form...) and returns _phptemplate_callback to a template file for further formatting.

When i theme this way the "Add" button and secondary pop ups do not work and i get the same error messages as the ones mentioned in this post.

If no fix for HS is possible in the short term - any idea of how i can do a "complete" theming of an exposed view that will not conflict with HS?

Comments

Hunabku’s picture

Component: Miscellaneous » Code - Taxonomy Views
Assigned: Hunabku » Unassigned
Priority: Critical » Normal

After poking around the issues more i can see that there are a lot of discussion related to theming exposed filters.

Wim i greatly appreciate the work you are doing here - outstanding, and can somewhat appreciate the challenges you are facing having to work around the architecture of Drupal. I would still be open to any suggestions you have about theming exposed views.

PS" i upgraded to 5.x-3.x-dev and will do some tests on that.

sdsheridan’s picture

I put these two functions in my template.php file for my theme, and they are working nicely for my exposed filters vis-a-vis formatting, theming, etc. Might help some folks...

shawn

/**
 * Improve the layout of exposed filters.
 * @param $form
 *   The view with the exposed filters.
 * @return the result of the form rendering.
 *
 * Modification made by SDSheridan, 31/10/2007.
 */
function phptemplate_views_filters($form) {

  define( "NUM_COLS", 5 );  // number of columns / filters across the filter block / table
  
  $view = $form['view']['#value'];
  $number_exp_filters = count($view->exposed_filter);
  $output='<table border="0" cellpadding="2">';

  $i = 0;
  foreach ($view->exposed_filter as $count => $expose) {
  
    $i++;
    
    $label = '<div class="form-element-label">' . $expose['label'] . '</div>';
    
    $formelement = str_replace( 'form-select', 'form-filter-select', drupal_render($form["op$count"]) . drupal_render($form["filter$count"])); // replace the class for the filter list box so can theme this separately from form-select.
    $formelement = preg_replace( '/size="\d"/', 'size="6"', $formelement ); // Make all select boxes 6 items long so filters take less vertical space.
    
    $filter ='<div class="form-element-filter' . $count . ' form-element-' . $expose['label'].'">' . $label . $formelement . '</div>';

    if ( strpos( $formelement, "hierarchical-select-wrapper" ) !== false ) { // this is a hierarchical select filter, so give it its own row
      if ( $i % NUM_COLS != 1 ) {  // if we're currently at a column position other than the first position, fill in the rest of the cells
        for ( $j = ( $i - 1 ) % NUM_COLS; $j < NUM_COLS; $j++ ) {
          $output .= '<td></td>';
        }
        $output .= '</tr>';  // end the row before rendering the hierarchical select filter in its own row
      }
      $output .= '<tr><td colspan="' . NUM_COLS . '">' . $filter . '</td></tr>';  // the hierarchical select filter in one cell spanning all columns
      $i = 0;  // Reset our modulus counter, since we'll be starting a new row of filters in column 1
    }
    else {

      if ($i % NUM_COLS == 0) {
        $output .= '<td valign="top">' . $filter . '</td></tr>';
      }
      else {
        if( $i % NUM_COLS == 1 ) {
          $output .= '<tr>';
        }
        $output .= '<td valign="top">' . $filter . '</td>';
      }
    }
  }
  
  if ($number_exp_filters % NUM_COLS != 0) {
    for ( $j = $i % NUM_COLS; $j < NUM_COLS; $j++ ) {
      $output .= '<td></td>';
    }
    $output .= '</tr>';
  }
  
  $form['reset'] = array( // Reset button for the filters
  '#type' => 'markup',
  '#value' => '<input '. drupal_attributes(array('type' => 'button', 'value' => t('Reset') )) .'class="form-submit" onClick="window.location = \'' .url($view->url) .'\';" />',
  '#weight' => 19,
  );
  
  $output .= '<tr><td colspan="' . NUM_COLS . '">' . '<div class="form-submit-button">' . drupal_render($form['submit']) . drupal_render($form['reset']) . '</div>' . '</td></tr>';
  $output .= '</table>';
  return drupal_render($form['q']) . $output . drupal_render($form);
}


// function to put filters into a collapsible fieldset

function theme_views_display_filters_userlist($view) {

  drupal_add_js('misc/collapse.js');

  $form = drupal_retrieve_form('views_filters',$view);
  $form['#prefix']='<fieldset class="collapsible  collapsed"><legend>Search Criteria (click here to open/close)</legend><div class="form-item" id="filter_userlist">';
  $form['#suffix']='</div></fieldset>';
  drupal_process_form('views_filters', $form);
  return drupal_render_form('views_filters', $form);
} 
wim leers’s picture

Status: Active » Closed (fixed)

Something like this is already in the README, but it's much simpler than this (without the "specific" stuff), which is why I won't refer to your comment from the README. I trust users will find it themselves. Thanks! :)