在node.tpl.php中渲染条件$ region - Drupal 7

时间:2017-08-18 23:46:56

标签: drupal drupal-7 drupal-regions

我试图打印一个条件区域,但我的代码似乎没有那么好用。有人可以帮忙解决问题吗?

<?php if (!empty($region['billboard'])): ?>
  <aside class="col-xs-0 col-sm-12" role="banner"> 
    <?php
        $region = block_get_blocks_by_region('billboard');
        print render($region);
        ?>
  </aside>
<?php endif;?>

以防万一有人在寻找这个片段,下面显示的代码用于将区域插入Drupal 7中的node.tpl.php。

<?php
$region = block_get_blocks_by_region('billboard');
print render($region);
?>

请查看下面的PraveenKumar回复,了解相同代码的条件替代方案。

1 个答案:

答案 0 :(得分:2)

试试这个。

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

希望这会对你有所帮助。

相关问题