Drupal 7 编辑Drupal 7模板-node.tpl.php

Drupal 7 编辑Drupal 7模板-node.tpl.php,drupal-7,drupal-theming,Drupal 7,Drupal Theming,使用Drupal 7如何自定义node.tpl.php以在标题前显示图像。 我喜欢将我的html标记结构组织为: <div id="node-id" class="class"> <div class="content"> <div class="field-name-field-graphic"><img src="Untitled-2.png"></div> <h2>tilte</h2>

使用Drupal 7如何自定义node.tpl.php以在标题前显示图像。 我喜欢将我的html标记结构组织为:

<div id="node-id" class="class">
  <div class="content">
    <div class="field-name-field-graphic"><img src="Untitled-2.png"></div>
    <h2>tilte</h2>
    <div class="field field-name-body">
      <p>body</p>
    </div>
  </div>
</div>

倾斜
身体

在“node.tpl.php”中,我没有看到字段名字段图形的变量。这是在哪里处理的

下面是node.tpl.php

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
  </div>

  <?php print render($content['links']); ?>

  <?php print render($content['comments']); ?>

</div>

您可以在$node变量内找到它,该变量是拥有所有数据的节点的对象。

您可以在$node变量内找到它,该变量是拥有所有数据的节点的对象。

您可以在$node变量内找到它,该变量是拥有所有数据的节点的对象。

您可以在$node内找到它变量,它是包含所有数据的节点的对象。

此行
打印渲染($content)
打印所有节点内容,所以要打印一个特定字段,可以这样做:
打印渲染($content['field\u name\u field\u graphic')

此行
打印渲染($content)
打印所有节点内容,所以要打印一个特定字段,可以这样做:
打印渲染($content['field\u name\u field\u graphic')

此行
打印渲染($content)
打印所有节点内容,所以要打印一个特定字段,可以这样做:
打印渲染($content['field\u name\u field\u graphic')

此行
打印渲染($content)
打印所有节点内容,所以要打印一个特定字段,可以这样做:
打印渲染($content['field\u name\u field\u graphic')

如果代码有帮助,请查看下面的代码

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
   <div class="field-name-field-graphic"> <?php print render($content['field_name_field_graphic']);?> </div>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_name_field_graphic']);
      print render($content);
    ?>
  </div>

  <?php print render($content['links']); ?>

  <?php print render($content['comments']); ?>

</div>

如果代码有帮助,请浏览下面的代码

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
   <div class="field-name-field-graphic"> <?php print render($content['field_name_field_graphic']);?> </div>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_name_field_graphic']);
      print render($content);
    ?>
  </div>

  <?php print render($content['links']); ?>

  <?php print render($content['comments']); ?>

</div>

如果代码有帮助,请浏览下面的代码

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
   <div class="field-name-field-graphic"> <?php print render($content['field_name_field_graphic']);?> </div>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_name_field_graphic']);
      print render($content);
    ?>
  </div>

  <?php print render($content['links']); ?>

  <?php print render($content['comments']); ?>

</div>

如果代码有帮助,请浏览下面的代码

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
   <div class="field-name-field-graphic"> <?php print render($content['field_name_field_graphic']);?> </div>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_name_field_graphic']);
      print render($content);
    ?>
  </div>

  <?php print render($content['links']); ?>

  <?php print render($content['comments']); ?>

</div>