mr.b
mr.b

Reputation: 2708

Drupal: How to display block/region in views page?

I have a views page that contains a listing of one of my content type. I used views-view-list--<name of my view>.tpl to theme the page. However, the region/blocks that I defined are not displaying. In other pages it works fine, but on the views page it does not. I'm trying to display a user login block in my defined region.

Please tell me how to access my user login block or my region to display on my views.

Your help is greatly appreciated. I'm using drupal 6 by the way.

Best regards,

Upvotes: 0

Views: 4705

Answers (5)

Bambolero
Bambolero

Reputation: 1

This is how the snippet will work for Drupal 7 with Bootstrap - HTML tags, considering that the 'billboard' region host an ad:

          <aside class="col-xs-0 col-sm-12 role="banner"> 
            <?php
                $region = block_get_blocks_by_region('billboard');
                print render($region);
                ?>
          </aside>

Upvotes: -1

Brooke Neace
Brooke Neace

Reputation: 1

This worked for me, except the syntax above needs semi-colons after (); for example print render($region); otherwise thank you for this answer

Upvotes: 0

npoku
npoku

Reputation: 31

As I am writing this, a safer and maybe recommended way in D7 would be:

<?php 
  $region = block_get_blocks_by_region('footer') //first define the block;
  print render($region) // then print the block; 
?>

I tried @Garry but I got some errors back from Drupal. Please see here

Hope this helps someone down the line.

Upvotes: 2

Garry
Garry

Reputation: 454

Think i ran into something similar yesterday. I was trying to print a region, for example

<?php print $footer ?>

but inside a tpl file that came from views - and for whatever reason, it doesn't output the region from one of the views tpl files.

I used this code:

<?php print theme('blocks', footer); // change "footer" to the name of your region ?>

Upvotes: 3

ArK
ArK

Reputation: 21068

Any page in drupal have page template based on url or content type . So you have to create right page template for your page where views page/block to be displayed. I'm assuming that you are using page template based on url

Upvotes: 0

Related Questions