I'm trying to print each exposed filter widget separately. Below is the foreach that prints all the widgets at the same time (via views-exposed-form.tpl.php). How would I go about printing them separately?

 <?php foreach ($widgets as $id => $widget): ?>  
     <label for="<?php print $widget->id; ?>">
          <?php print $widget->label; ?>
     </label>
          <?php print $widget->id; ?>
<?php endforeach; ?> 

Doing print_r function on $widgets shows the ff: array:

 Array
(
    [filter-tid] => stdClass Object
        (
            [widget] => 
Option 1
Option 2
Option 3
            [operator] => 
            [label] => label here
            [id] => edit-id-here
        )

    [filter-tid_1] => stdClass Object
        (
            [widget] => 
Option 1
Option 2
Option 3
            [operator] => 
            [label] => label here
            [id] => edit-id-here
        )
   
   ....... and so on.... 

Comments

halloffame’s picture

Status: Active » Fixed
 <?php $widget = $widgets['filter-tid'] ?> 
     <label for="<?php print $widget->id; ?>">
          <?php print $widget->label; ?>
     </label>
          <?php print $widget->id; ?> 

I always enjoy talking to myself...

Status: Fixed » Closed (fixed)

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

Renee S’s picture

Hah, thanks for the snippet -- also enjoyed the commentary ;)

Renee S’s picture

Issue summary: View changes

typo