如何在node.tpl.php中使用DISPLAY SUITE的新自定义字段(Drupal 7)

发布于 2024-12-21 14:43:52 字数 430 浏览 2 评论 0原文

我现在正在开发一个 drupal 7 项目,该项目基本上基于 Facebook 等社交网络。

我们在其中包含了Heartbeat模块之一,我们在其中进行了一些自定义操作,并从Display Suite模块创建了一个自定义字段。我已经制作了这个自定义字段,并且可以与 Heartbeat 模块配合使用,但现在我们需要在所有其他实体中显示此自定义字段,例如 nodecomments、<强>用户个人资料等.. 我很努力地去做,但未能成功。谁能给我提示如何在 node.tpl.php 文件中使用这些自定义显示套件字段

提前致谢。

问候, 钱德雷什。

I'm right now working on one of the drupal 7 project, which is basically based on Social networking like facebook.

Where we are including one of the module Heartbeat, in which we have done some customization and create one custom field from the Display Suite module. i have made this custom field and which is working good with Heartbeat module, but now we need required to display this custom field in all the other entity like node, comments, user profile etc..
I tried hard to do it but can't get success on. Can anyone give me hint how to use those custom display suite fields in node.tpl.php file ??

Thanks in advance.

Regards,
Chandresh.

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

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

发布评论

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

评论(1

风情万种。 2024-12-28 14:43:52

在您的node.tpl中,您必须使用以下代码,例如字段名称:field_header

 <!-- For Showing only custom field's Value Use below code -->
 <h2 class="title"><?php print $node->field_header['und']['0']['value'];?></h2>

 <!-- ========================= OR  ========================= -->

 <!-- For Showing custom field Use below code , which shows custom field's value and title-->
 <h2 class="title"><?php print render(field_view_field('node', $node, 'field_header'));  ?></h2>

 <!-- ========================= OR  ========================= -->

 <h2 class="title"><?php print render($content['field_header']); ?></h2>

In your node.tpl you have to use following code, for example field name : field_header

 <!-- For Showing only custom field's Value Use below code -->
 <h2 class="title"><?php print $node->field_header['und']['0']['value'];?></h2>

 <!-- ========================= OR  ========================= -->

 <!-- For Showing custom field Use below code , which shows custom field's value and title-->
 <h2 class="title"><?php print render(field_view_field('node', $node, 'field_header'));  ?></h2>

 <!-- ========================= OR  ========================= -->

 <h2 class="title"><?php print render($content['field_header']); ?></h2>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文