如何在程序化$节点输出的主题('node',$ node)和drupal_render($ node->内容之间) [英] How do I decide between theme('node', $node) and drupal_render($node->content) for programmatic $node output

查看:115
本文介绍了如何在程序化$节点输出的主题('node',$ node)和drupal_render($ node->内容之间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个 $ node ,我试图通过以下两种方式来确定$节点。

Given a $node, I'm trying to decide between the following two ways of outputting that $node.

$output = theme('node', $node);

node_build_content($node);
$output = drupal_render($node->content);

他们似乎都提供了类似的结果,但是在我选择一种方式之前,我应该考虑一些事情另一个?

They both seem to give similar results, but is there something I should consider before I choose one way over the other?

推荐答案

如果没有其他模块和主题通过主题层更改输出,则输出类似。

Your output is similar if there are no other modules and themes altering the output via the theme layer.

但是!如果您绕过主题图层,则当您安装模块或主题并更改使用主题图层更改节点输出的配置设置时,您可能会开始遇到意外行为。

But! If you bypass the theme layer, you'll probably start experiencing unexpected behaviour when you install modules or themes and change config settings that use the theme layer to alter the node's output.

简而言之,通过绕过主题图层,您在应用程序中构建错误。将您的应用程序转交给开始更改admin /

In short, by bypassing the theme layer, you're building error into your application. These error are likely to occur after you hand your application over to someone (a client perhaps) who starts changing settings in admin/

中的设置的某人(可能是客户端)可能会发生这些错误,如果您有兴趣,请参阅装饰器模式。 Drupal广泛使用。

See the decorator pattern if you're interested. Drupal uses this extensively.

http:// en .wikipedia.org / wiki / Decorator_pattern

这篇关于如何在程序化$节点输出的主题('node',$ node)和drupal_render($ node->内容之间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆