开发者

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>开发者_JS百科;.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,


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 ?>


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.


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


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


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜