Drupal: Overriding views_exposed_form

DrupalHave a custom view, it's displayed as a block, but I don't want the search button in it (since there are more than 10 views on a single page I don't want every single one of them to have a search form).

To remove the search form or exposed form, as it is called in views, you need to:

  1. Save sites/all/modules/views/theme/views-exposed-form.tpl.php somewhere on your computer.
  2. Open it in your favorite text editor.
  3. Edit its content according to your needs.
    In my case I commented out the code I don't need/want:
    <?php /*?><div class="views-exposed-widgets clearfix">
        <?php foreach ($widgets as $id => $widget): ?>
          <div id="<?php print $widget->id; ?>-wrapper" class="views-exposed-widget views-widget-<?php print $id; ?>">
            <?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>
            <?php if (!empty($widget->description)): ?>
              <div class="description">
                <?php print $widget->description; ?>
              </div>
            <?php endif; ?>
          </div>
        <?php endforeach; ?>
        <?php if (!empty($sort_by)): ?>
          <div class="views-exposed-widget views-widget-sort-by">
            <?php print $sort_by; ?>
          </div>
          <div class="views-exposed-widget views-widget-sort-order">
            <?php print $sort_order; ?>
          </div>
        <?php endif; ?>
        <?php if (!empty($items_per_page)): ?>
          <div class="views-exposed-widget views-widget-per-page">
            <?php print $items_per_page; ?>
          </div>
        <?php endif; ?>
        <?php if (!empty($offset)): ?>
          <div class="views-exposed-widget views-widget-offset">
            <?php print $offset; ?>
          </div>
        <?php endif; ?>
        <div class="views-exposed-widget views-submit-button">
          <?php print $button; ?>
        </div>
        <?php if (!empty($reset_button)): ?>
          <div class="views-exposed-widget views-reset-button">
            <?php print $reset_button; ?>
          </div>
        <?php endif; ?>
      </div><?php */?>
  4. Rename this file as you named your custom view, ex. 'views-exposed-form--yourviewname.tpl.php'
  5. Upload the saved file into your sites/all/themes/yourtheme folder.
  6. Clear site cache and reload your page.

Izdelava spletnih strani ganesa.si

Izdelava spletnih strani ganesa.si