【问题标题】:How to use new custom field of DISPLAY SUITE in node.tpl.php (Drupal 7)如何在node.tpl.php(Drupal 7)中使用DISPLAY SUITE的新自定义字段
【发布时间】:2011-12-14 09:02:44
【问题描述】:

我现在正在从事 drupal 7 项目之一,该项目基本上基于 Facebook 等社交网络。

我们在其中包含一个模块 Heartbeat,我们在其中进行了一些自定义,并从 Display Suite 模块创建了一个自定义字段。我已经制作了这个自定义字段,它与 Heartbeat 模块配合得很好,但现在我们需要在所有其他实体中显示这个自定义字段,如 nodecmets、用户资料等.. 我努力去做,但无法成功。谁能给我提示如何在 node.tpl.php 文件中使用那些自定义的显示套件字段??

提前致谢。

问候, 钱德雷什。

【问题讨论】:

  • 该死的。 更多社交网站。
  • 不用担心...它只适用于情侣.. :)
  • 你能告诉我们你已经尝试过什么吗?
  • 我已经实现了模块,并且还从显示套件创建了一个自定义字段,但我想知道如何将此自定义字段调用到 node.tpl.php 页面中。??

标签: php drupal drupal-7 drupal-modules


【解决方案1】:

在您的 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多