简体   繁体   English

Drupal,如何在节点的“内容”中渲染块?

[英]Drupal , how to render block in 'content' of a node?

I have a common content in few pages. 我在几页中有一个共同的内容。 And I want include the content in 'content' of a node. 我想将内容包含在节点的“内容”中。

What I thought is use block, but I don't know how to use block in 'content' of a node. 我以为是使用块,但我不知道如何在节点的“内容”中使用块。 There is still some other different "div" wrapping the block, and I can't write the block in template file. 还有其他一些不同的“ div”包装块,并且我无法在模板文件中写入该块。 What should I do? 我该怎么办? Thanks! 谢谢!

I would avoid rendering a block directly within the content of a page. 我会避免直接在页面内容中呈现块。

Instead make a new region directly above or below the content (depending on where you want your block to appear) and then put then block in the new region. 而是在内容的上方或下方直接创建一个新区域 (取决于您希望显示块的位置),然后将块放置在新区域中。

It is also possible to render your block directly in the template file using 也可以使用以下命令直接在模板文件中渲染块

$block = module_invoke('modulename', 'block_view', 'block_name');
print render($block);

This post discusses the merits of both methods: http://drupal.org/node/345361 这篇文章讨论了这两种方法的优点: http : //drupal.org/node/345361

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM