drupal7在page中直接输出区块

//正规方法:
$block
= block_load('block', '1');// block_load($module, $delta) block.module 行 714 $output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block)))); print $output; //分开写是这样的: $block = block_load($module, $block_id); $block_content = _block_render_blocks(array($block)); $build = _block_get_renderable_array($block_content); $block_rendered = drupal_render($build);

 简单暴力的获取区块的输出内容如下,我在page里想通过上面的方法输出我自定义区块,结果报错Notice: Only variables should be passed by reference,研究一番,就用了下面的方法:

   $module='obcustom';
    $delta='thinkers_bottom_end';
    $block = block_load($module, $delta);  
    $block_content = _block_render_blocks(array($block));  
    $key=$module.'_'.$delta;
    if(!empty($block_content[$key]->content['#markup'])){
      print $block_content[$key]->content['#markup'];
    }

 

posted @ 2017-07-19 15:51  jiafeng  阅读(313)  评论(0编辑  收藏  举报