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

这里的技术是共享的

You are here

Drupal 7 模板改写建议 顺序

shiping1 的头像

Drupal 7 模板改写建议

猪跑啦独家原创专稿,欢迎您转载本文,转载请注明来源。

原文:Drupal 7 Template (Theme Hook) Suggestions

核心默认主题改写建议

区块

基模板:block.tpl.php
block--[region|[module|--delta]].tpl.php
查找顺序:

  1. block--module--delta.tpl.php
  2. block--module.tpl.php
  3. block--region.tpl.php

例子:block--block--1.tpl.php,block--sidebar_first.tpl.php,block--custom--my-block.tpl.php

 

评论

基模板:comment.tpl.php
comment--node-[type].tpl.php
例子:comment--node-article.tpl.php

基模板:comment-wrapper.tpl.php
comment-wrapper--node-[type].tpl.php
例子:comment-wrapper--node-article.tpl.php

字段

基模板:field.tpl.php
field--[type|name[--content-type]|content-type].tpl.php
查找顺序:

  1. field--field-name--content-type.tpl.php
  2. field--content-type.tpl.php
  3. field--field-name.tpl.php
  4. field--field-type.tpl.php

例子:field--field-phone.tpl.php

论坛

基模板:forums.tpl.php
forums--[[container|topic]--forumID].tpl.php
查找顺序:
论坛容器

  1. forums--containers--forumID.tpl.php
  2. forums--forumID.tpl.php
  3. forums--containers.tpl.php

论坛主题

  1. forums--topics--forumID.tpl.php
  2. forums--forumID.tpl.php
  3. forums--topics.tpl.php

HTML模板

基模板:html.tpl.php

维护状态

基模板:maintenance-page.tpl.php
maintenance-page--[offline].tpl.php

节点

基模板:node.tpl.php
node--[type|nodeid].tpl.php
查找顺序:

  1. node--nodeid.tpl.php
  2. node--type.tpl.php
  3. node.tpl.php

基模板:page.tpl.php
page--[front|internal/path].tpl.php
查找顺序(例子http://www.example.com/node/1/edit):

  1. page--node--edit.tpl.php
  2. page--node--1.tpl.php
  3. page--node.tpl.php
  4. page.tpl.php

投票

基模板:poll-results.tpl.php
poll-results--[block].tpl.php

基模板:poll-vote.tpl.php
poll-vote--[block].tpl.php

基模板:poll-bar.tpl.php
poll-bar--[block].tpl.php

profile

基模板:profile-wrapper.tpl.php
profile-wrapper--[field].tpl.php

区域

基模板:region.tpl.php
region--[region].tpl.php

搜索

基模板:search-results.tpl.php
search-results--[searchType].tpl.php

分类

基模板:taxonomy-term.tpl.php
taxonomy-term--[vocabulary-machine-name|tid].tpl.php
查找顺序:

  1. taxonomy-term--tid.tpl.php
  2. taxonomy-term--vocabulary-machine-name.tpl.php
  3. taxonomy-term.tpl.php
来自 http://www.drupalla.com/node/1768
普通分类: