欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal 输出 node字段 变量

shiping1 的头像

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

However,

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

http://drupal.org/project/teaserbytype

 http://drupal.org/project/retease

张明辉的博客

drupal模板输出自定义字段

假使你的这个文章所在的内容类型叫 article

article 的 field_image 是放图片,title 是标题, body 是内容。

 

1,打开bartik主题的文件夹,找到node.tpl.php 复制一份 改名为 node--article.tpl.php

2,打开node--article.tpl.php 找到 print render($content); 改为 print render($content['field_image']);  清空缓存看看,这个时候,页面就只显示内容的图片部分,内容部分不见了

3,依次把其他字段一个一个的加上,这样就能自定义样式了。

如:

html:

1
2
3
4
5
<div class="drupalla">
  <div class="title"><?php print $title;?></div>
  <div class="pic"><?php print render($content['field_image']);?></div>
  <div class="desc"><?php print render($content['body']);?></div>
</div>

css:

1
2
3
4
.drupalla{width:600px;}
.drupalla .title{}
.drupalla .pic{float:left;width:150px;}
.drupalla .desc{float:left; width:300px;}

来源:http://www.drupalla.com/node/722

普通分类: