1

I want to have the views header elements after exposed filters, so i try to get the filters in the header. For that, i expose them in a block, and try to add that block to headers, but no success. I also tried to show the filters-block on the view's page (an admin path) via the block settings (show in content area, only on pages admin/content/myview), also no success.

To add a generic block to a views header via UI, there's the module https://www.drupal.org/project/views_block_area

On the module page it says

Blocks that are generated by views, can't be selected. These blocks can be inserted by views areas.

But i can't see how to do that. When i add a view area to my view's header, i have the view which generates the exposed-filters block, but the block is not listed, only the default and an attachment i have in that view.

2 Answers 2

0

The easiest way to do that is to modify your View template. Identify it in the third column (Advanced), section Theme : informations (by default views-view.tpl.php). Find it (usually in sites/all/modules/views/theme). Then you will just have to reorganize this tpl file. In your case, you just need to switch two sections like this :

<?php if ($exposed): ?>
<div class="view-filters">
  <?php print $exposed; ?>
</div>
<?php if ($header): ?>
<div class="view-header">
  <?php print $header; ?>
</div>
2
  • Thanks. I was hoping for (php-)coding-free way, to do that. You say 'easyest way'... so, might there be a way through the admin ui? Maybe a hack with some css, or moving html via js? Sounds ugly...
    – sirtet
    Commented Mar 19, 2015 at 20:58
  • Actually, I would have proceeded just like you, at first sight. By exposing your filters in a block and configuring the block (in the right theme region, only on page "your-view-url") so it would appear before the complete view and thus the view header. I can not tell why it did not work for you.
    – Toki
    Commented Mar 20, 2015 at 13:12
0

Add views block to views header: Drupal 8/9/10

This can be done from backend by voew UI

Install & enable twig tweak module

Edit particular view & click on header section, add following code:

{{ drupal_view('view_name', 'display_name') }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.