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

这里的技术是共享的

You are here

覆写字段方法

shiping1 的头像
google   drupal override node field





覆写字段的顺序
leyouji_field__field__feedom_tags()
Candidate function names:
leyouji_field__field__feedom_tags___spot
< leyouji_field___spot <
leyouji_field__field__feedom_tags
< leyouji_field__taxonomy_term_reference
< leyouji_field
Preprocess functions:
template_preprocess_field + rdf_preprocess_field
Process functions:
template_process_field


假使你的这个文章所在的内容类型叫 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:
<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>
普通分类: