本文介绍了如何在Drupal 7中将块插入节点或模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在的Drupal 6,很容易插入块成用下面的代码的模板:
In Drupal 6, it was easy to insert a block into a template with the following code:
$block = module_invoke('views', 'block', 'view', 'block_name');
print $block['content'];
但是,在Drupal 7中使用相同的指令似乎不起作用。我环顾四周,并不能找到新的方法。
However, using the same instructions in Drupal 7 does not seem to work. I have looked around and cannot find the new method.
请问Drupal的7有一个例行程序,可以允许亲语法插入块到模板或节点?
Does Drupal 7 have a routine that can allow for pro grammatically inserting a block into a template or node?
推荐答案
通过wrburgess的答案,如果您的服务器使用PHP的新版本,你可能会得到一个错误。
With wrburgess's answer you may get an error if your server is using a newer version of PHP.
Strict warning: Only variables should be passed by reference in include()...
这是我做的,不会导致/摆脱错误。
This is what I did to not cause/get rid of the error.
<?php
$blockObject = block_load('views', 'block_name');
$block = _block_get_renderable_array(_block_render_blocks(array($blockObject)));
$output = drupal_render($block);
print $output;
?>
这篇关于如何在Drupal 7中将块插入节点或模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!