2011-04-26 40 views
3

我正在尝试在我创建的视图上的一组特定的暴露过滤器上放置一些样式。如何在视图中为主题暴露的过滤器项目 - Drupal 6

该视图被称为user_search,因此我创建了views-exposed-form-user-search.tpl.php,并且没有工作(它所做的只是删除暴露的过滤器,但仍显示视图)。 views-exposed-form-user-search-page.tpl.php也得到了相同的结果。

即使它确实起作用了,我仍然不知道该如何放置窗体才能显示,以便我可以添加样式或容器div。

print drupal_render($form);没有工作。

回答

8

经过大量的挖掘,我找到了一个解决方案。

首先,你必须找到应该位于sites/all/modules/views/theme/文件夹中的views-exposed-form.tpl.php文件。我们使用的是acquia stack,因此它位于vendor/文件夹中。

拷贝到themes/YOUR-THEME/文件夹并将其重命名为views-exposed-form--your-view-name.tpl.php

如果你只是想影响你的看法命名的特定显示器views-exposed-form--your-view-name--display.tpl.php

然后,您可以使用现有的框架来编辑它,你觉得合适。这是一个例子。

<?php 
// $Id: views-exposed-form.tpl.php,v 1.4.4.1 2009/11/18 20:37:58 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 for="<?php print $widget->id; ?>"> 
      <?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> 
1

如果不确定如何为页面的某个部分设置主题,请安装Theme Developer module。它将允许您查看当前正在输出页面特定区域的主题文件或函数,以及可以使用哪些文件或函数来覆盖它。有关更多详细信息,请参阅screencast

相关问题