Code for no fieldset theme

davidwhthomas - August 20, 2007 - 23:27
Project:Views Filter Block
Version:5.x-1.2
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:active
Description

I modified the theme function to return a plain list of filter form elements
I'm planning on adding as a config option which output method to chose.
Here's the theme code for plain view:

<?php
function theme_views_filterblock($form) {
 
$view = $form['view']['#value'];

 
// make the 'q' come first
 
$output = drupal_render($form['q']);

  foreach (
$form as $field => $value) {
    if (
preg_match('/(op|filter)([0-9]+)/', $field, $match)) {
     
$curcount = $match[2];
     
$newform[$field] = $value;

     
$newform[$field]['#weight'] = $curcount; //assign weighting
     
     
if (!isset($newform[$field]['#title'])) {
       
$newform[$field]['#title'] = $view->exposed_filter[str_replace('filter','',$value['#name'])]['label'];
      }
      if (
$newform[$field]['#type']=='textfield') {
      
$newform[$field]['#attributes'] = array('style'=>'width: 15em;'); //shrink textfield elements
     
}
    }
    else {

      if (
$field == 'submit' || drupal_substr($field, 0, 1) == '#') {
        unset(
$curcount);
      }
      if (isset(
$curcount)) {
       
$newform[$field] = $value;
      }
      else {
       
$newform[$field] = $value;
      }
    }
  }
   
$newform['submit']['#weight'] = 100; //fix submit button weighting to come last
   
 
return theme('views_filterblock_output', $newform);
}

?>

#1

douggreen - August 20, 2007 - 23:36

David, Thanks! Are you proposing a patch? such as allowing the administrator to pick between the fieldset block and a non fieldset block?

I'm not sure if you're modifying the code for views_filterblock or if you've added a function to your theme for this. But the Drupal way is to add your new function in your theme template.php, but name is _phptemplate_views_filterblock or {yourthemename}_views_filterblock. That's why this function is a theme function, so that you can easily override it with something like what you've done here.

#2

davidwhthomas - August 21, 2007 - 02:02

Hi Doug,

Yep, I added that function into the views_filterblock.module file though a theme override would be a good solution too.

I just adding an admin setting to allow the 'block style' selection.

Depending upon the user selection, the theme function will return the corresponding output.

thanks for your work on this, much appreciated :-)

I've attached my updated version of views_filterblock.module

regards,

DT

#3

davidwhthomas - August 21, 2007 - 02:03

Drupal ate my attachment, one more try...

AttachmentSize
views_filterblock .txt 7.42 KB

#4

futurist - August 30, 2007 - 14:02

Nice feature, was trying to get rid of the fieldset too. Doug, is this going to be in 5.x-1.3? Thanks to both of you!

#5

douggreen - August 31, 2007 - 19:54

No, not going to be in 5.x-1.3. If anyone wants to submit a patch... I'd like to see this an option on the block settings page, and off by default.

#6

dalvir - February 3, 2009 - 19:36

hi david

nice feature,
but i find that
it should return that

return $output . theme('views_filterblock_output', $newform);

instead of
return theme('views_filterblock_output', $newform);

then its working fine otherwise it goes to frontpage without result.
dalvir

 
 

Drupal is a registered trademark of Dries Buytaert.