如何在视图中主题公开过滤器项目 - drupal 6

Ora*_*s13 3 views drupal-views drupal-6

我试图在我创建的视图上的一组特定的公开过滤器上添加一些样式.

该视图称为user_search,因此我创建了views-exposed-form - user-search.tpl.php并且不起作用(它所做的只是删除了公开的过滤器,但仍然显示了视图).views-exposed-form - user-search - page.tpl.php也得到了相同的结果.

即使它确实有效,我仍然不知道要放在哪里以显示表单,只是为了我可以添加样式或容器div.

print drupal_render($form); 不工作.

Ora*_*s13 8

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

首先,您必须找到views-exposed-form.tpl.php文件,该文件应位于sites/all/modules/views/theme/文件夹中.我们正在使用acquia堆栈,因此它位于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>
Run Code Online (Sandbox Code Playgroud)