Drupal 6:将所有正文字段内容打印到节点模板文件

发布于 2024-09-04 11:26:40 字数 201 浏览 5 评论 0原文

我尝试显示正文内容:

<?php print $node->content['body']['#value']; ?>

但是,它不显示所有正文内容,它只显示正文内容的第一段,如果很短,有时会显示 2 段:/

我需要打印所有正文。我怎样才能做到这一点?

多谢!赞赏有帮助!

I tried to display body content with:

<?php print $node->content['body']['#value']; ?>

However, it doesn't display all body content, it just display first paragraph of body content, sometimes 2 paragraph if it is short :/

I need to print all body. how can I do that?

Thanks a lot! Appreciate helps!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慕烟庭风 2024-09-11 11:26:40

缩短的正文内容暗示它被填充/渲染为“预告片”视图而不是“完整”视图。您在什么情况下发布此打印声明?


编辑:节点模板通常用于预告片和完整输出,但使用什么的决定以及节点对象中内容条目的填充发生在节点模板文件之外。在节点模板文件中,如果节点要显示为预告片,则变量 $teaser 将为 TRUE。

因此,您需要检查调用节点模板的上下文,因为您必须配置该上下文才能将节点呈现为“完整”。这可能在很多地方,具体取决于谁负责提供您想要主题化的节点,例如,如果从视图调用节点模板,您需要将视图配置为使用“全页”输出,如果它来自模块,您需要检查模块设置等......

The shortened body content hints on it being filled/rendered for 'teaser' view instead of 'full'. In what context do you issue this print statement?


EDIT: The node templates are usually used for both, teaser and full output, but the decision on what to use, as well as the population of the content entries in the node object happen outside of the node template files. Within the node template file, the variable $teaser will be TRUE, if the node is to be shown as a teaser.

So you need to check in what context your node template gets called, as you'll have to configure that context to render the node as 'full'. This could be in many places, depending on who is responsible to provide the nodes you want to theme, e.g. if the node template gets called from a view, you'll need to configure the view to use 'full page' output, if it comes from a module, you'll need to check with the module settings, etc...

掐死时间 2024-09-11 11:26:40

node.tpl.php 中尝试

<?php print $content ?>

但是,

<?php print $node->content['body']['#value']; ?>

也对我有用。

In node.tpl.php try

<?php print $content ?>

However,

<?php print $node->content['body']['#value']; ?>

works for me as well.

病女 2024-09-11 11:26:40

为了控制预告片的长度,可以使用“发布设置”来设置主值。
(修剪帖子的长度)

要通过节点类型控制它,请尝试: http://drupal.org/project/teaserbytype< /a>

注意:预告片已被缓存,因此您需要 http://drupal.org/project/retease< /a>

但是,如果您只想在节点模板中完成它,您可以运行 node_load() 并拥有一切...但这不是最佳实践。

仅供参考:您可以控制显示选项下 $content 中显示的 CCK 字段。

PS:在 Teaser 模式下,我经常使用 truncate_utf8()。

To get control over your teaser length the master value is set with Post Settings.
(Length of trimmed posts)

To control this by node type try: http://drupal.org/project/teaserbytype

NOTE: Teasers are cached so you'll need to http://drupal.org/project/retease

However, if you want to just get it done in the node template you could run a node_load() and have everything... but that's not the best practice.

FYI: you can control what CCK fields show up in $content under Display Options.

PS: In teaser mode I often make use of truncate_utf8().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文