Hello,

I am trying to theme my exposed filter and based on an earlier discussion there are tpl.php files for these. For example:
I notice these do not appear in Theme Information, should they?

<?php
// $Id: views-exposed-form.tpl.php,v 1.4 2008/05/07 23:00:25 merlinofchaos Exp $
/**
* @file views-exposed-form.tpl.php
*
* This template handles the layout of the views exposed filter form.
*
* Variables available:
* - $widgets: An array of exposed form widgets. Each widget contains:
* - $widget->label: The visible label to print. May be optional.
* - $widget->operator: The operator for the widget. May be optional.
* - $widget->widget: The widget itself.
* - $button: The submit button for the form.
*
* @ingroup views_templates
*/
?>
<?php if (!empty($q)): ?>
  <?php
    // This ensures that, if clean URLs are off, the 'q' is added first so that
    // it shows up first in the URL.
    print $q;
  ?>
<?php endif; ?>
<div class="views-exposed-form">
  <div class="views-exposed-widgets clear-block">
    <?php foreach($widgets as $id => $widget): ?>
      <div class="views-exposed-widget">
        <?php if (!empty($widget->label)): ?>
          <label>
            <?php print $widget->label; ?>
          </label>
        <?php endif; ?>
        <?php if (!empty($widget->operator)): ?>
          <div class="views-operator">
            <?php print $widget->operator; ?>
          </div>
        <?php endif; ?>
        <div class="views-widget">
          <?php print $widget->widget; ?>
        </div>
      </div>
    <?php endforeach; ?>
    <div class="views-exposed-widget">
      <?php print $button ?>
    </div>
  </div>
</div>
CommentFileSizeAuthor
#7 2010-06-03_2143.png26.97 KBBilmar
#4 views-726650.patch1.75 KBdagmar

Comments

jordanmagnuson’s picture

Subscribing... I'm trying to theme my exposed filters in Views 3, and not having any luck so far.

tribe_of_dan’s picture

Subscribe

dawehner’s picture

It would be easy to show the exposed filter tpl. But you cannot make it currently per view.

dagmar’s picture

Status: Active » Needs review
StatusFileSize
new1.75 KB

Mmm, I'm are not completely sure if exposed forms cannot be used with templates.

In my opinion only this info is not provided by the View UI.

Dereine, what do you think about this patch?

if you see this function

function _views_theme_functions($hook, $view, $display = NULL) {
  $themes = array();

  if ($display) {
    $themes[] = $hook . '__' . $view->name . '__' . $display->id;
    $themes[] = $hook . '__' . $display->id;
    $themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '-', strtolower($view->tag));
    if ($display->id != $display->display_plugin) {
      $themes[] = $hook . '__' . $view->name . '__' . $display->display_plugin;
      $themes[] = $hook . '__' . $display->display_plugin;
    }
  }
  $themes[] = $hook . '__' . $view->name;
  $themes[] = $hook;
  return $themes;
}

And this line of code:

$form['#theme'] = views_theme_functions('views_exposed_form', $view, $display);

It seems to be loading all this template functions.

So this patch make this template alternatives visible when there are exposed forms for the current display.

gooddesignusa’s picture

subscribing

Bilmar’s picture

Hello,

I applied the patch at #4 and now see the section 'Exposed form output' in Theming Information. However, it seems like the exposed form template file that is being used is not highlighted after clicking [Rescan template files].

I currently have views-exposed-form--search.tpl.php in the theme folder and it is being registered properly by drupal when looking at the exposed form (just in the Theming Information section it is not highlighted as the template being used).

Regards

Bilmar’s picture

StatusFileSize
new26.97 KB

oops, the image didn't attach properly

YK85’s picture

+1 subscribing

giorgio79’s picture

Status: Needs review » Reviewed & tested by the community

#6

Bilmar’s picture

Status: Reviewed & tested by the community » Needs review

As per my comments in #6, this isn't working properly yet.
This should be 'needs work' or 'needs review' so others can further test the patch at #4.
As this feature might get lost in the 'needs work' world, I'm setting back to 'needs review' =)

Thanks

dagmar’s picture

Status: Needs review » Needs work

Correct status is need works.

xjm’s picture

Tracking.

Letharion’s picture

Assigned: Unassigned » merlinofchaos

Assigning to Merlin to draw some attention to this issue. :)

mustanggb’s picture

Status: Needs work » Closed (won't fix)