2011-04-26 62 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

相關問題