继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

Drupal主题系统-到底有些什么-drupal系统模板文件template files

前面建立了第一步,建立了一个hellodrupal.info的文件,就是告诉drupal系统,我要建立自己的drupal主题模板了。其实我也觉得我这个默认的drupal主题系统模块没有个性,虽然很漂亮。没有美术艺术细胞,也不知道如果来改个主题。这几天在思考如何来定义一个自己的主题系统呢。先看看drupal官方的默认主题模板定义。可以到这里http://drupal.org/files/issues/Core_templates_and_suggestions.pdf 下载。其实用的最多的就是page.tpl.php 和node.tpl.php.还有block.tpl.php page.tpl.php可以控制界面的网站整体排版,node.tpl.php主要是节点信息,比如内容页面和列表页怎么样的来显示。 今天先看看主题系统开发指南的一些知识,再整理笔记。然后分模板文件来整理。先预备一些在模板里面可以用到的函数。 ******************************* page.tpl.php 模板变量 ******************************* node.tpl.php 模板变量 ******************************* node.tpl.php 模板变量 ******************************* Core templates and suggestions Default templates Aggregator "modules/aggregator/..." aggregator-feed-source.tpl.php aggregator-item.tpl.php aggregator-summary-item.tpl.php aggregator-summary-items.tpl.php aggregator-wrapper.tpl.php Block "modules/system/..." block.tpl.php "modules/block/..." block-admin-display-form.tpl.php Book "modules/book/..." book-all-books-block.tpl.php book-export-html.tpl.php book-navigation.tpl.php book-node-export-html.tpl.php Comment "modules/comment/..." comment-folded.tpl.php comment-wrapper.tpl.php comment.tpl.php Forum "modules/forum/..." forum-icon.tpl.php forum-list.tpl.php forum-submitted.tpl.php forum-topic-list.tpl.php forum-topic-navigation.tpl.php forums.tpl.php Node "modules/node/..." node.tpl.php Poll "modules/poll/..." poll-bar-block.tpl.php poll-bar.tpl.php poll-results-block.tpl.php poll-results.tpl.php poll-vote.tpl.php Profile "modules/profile/..." profile-block.tpl.php profile-listing.tpl.php profile-wrapper.tpl.php Search "modules/search/..." search-block-form.tpl.php search-result.tpl.php search-results.tpl.php search-theme-form.tpl.php User "modules/user/..." user-picture.tpl.php user-profile-category.tpl.php user-profile-item.tpl.php user-profile.tpl.php System "modules/system/..." page.tpl.php maintenance-page.tpl.php box.tpl.php Template suggestions Suggestions only work when they are placed in the same directory as the base template. In other words, trying to get comment-blog.tpl.php to work, comment.tpl.php also needs to exist inside your theme and in the same directory. Custom suggestions beyond the ones listed below can be created. See the page Working with template suggestions. block-[region|[module|-delta]].tpl.php base template: block.tpl.php Suggestions made based on these factors in this order: block-1. module-delta.tpl.php 2. block-module.tpl.php 3. block-region.tpl.php "module" being the name of the module and "delta", the internal id assigned to the block by the module. For example, "block-user-1.tpl.php" would be used for the default user navigation block since it was created by the user module with the id of 1. "region" will take effect for specific regions. comment-[type].tpl.php base template: comment.tpl.php Support was added to create commenttype. tpl.php files, to format comments of a certain node type differently than other comments in the site. Similar to node-[type].tpl.php but for comments. comment-wrapper-[type].tpl.php base template: comment-wrapper.tpl.php Similar to the above but for the wrapper template. forums-[[container|topic]-forumID].tpl.php base template: forums.tpl.php Template suggestions added based in these factors, in this order. For forum containers: forums-containers-1. forumID.tpl.php 2. forums-forumID.tpl.php 3. forums-containers.tpl.php For forum topics: 1. forums-topics-forumID.tpl.php 2. forums-forumID.tpl.php 3. forums-topics.tpl.php maintenance-page-[offline].tpl.php base template: maintenance-page.tpl.php This applies when the database fails. Useful for presenting a friendlier page without error messages. Theming the maintenance page must be properly setup first. node-[type].tpl.php base template: node.tpl.php Node content type, e.g., "node-story.tpl.php", "nodeblog. tpl.php", etc. page-[front|internal/path].tpl.php base template: page.tpl.php The suggestions are numerous. The one that takes precedence is for the front page. The rest are based on the internal path of the current page. Do not confuse the internal path to path aliases which are not accounted for. Keep in mind that the commonly used Path auto module works its magic through path aliases. The front page can be set through "Administrator > Site configuration > Site information". Anything set there will trigger the suggestion of "pagefront. tpl.php" for it. The list of suggested template files in order of specificity is based on internal paths. One suggestion is made for every element of the current path, though numeric elements are not carried to subsequent suggestions. For example, "http://www.example.com /node/1/edit" would result in the following suggestions: 1. page-node-edit.tpl.php 2. page-node-1.tpl.php 3. page-node.tpl.php 4. page.tpl.php poll-results-[block].tpl.php base template: poll-results.tpl.php The theme function that generates poll results are shared for nodes and blocks. The default is to use it for nodes but a suggestion is made for rendering them inside block regions. This suggestion is used by default and the template file is located inside "modules/poll/poll-results-block.tpl.php". poll-vote-[block].tpl.php base template: poll-vote.tpl.php Similar to poll-results-[block].tpl.php but for generating the voting form. You must provide your own template to for it to take effect. poll-bar-[block].tpl.php base template: poll-bar.tpl.php Same as poll-vote-[block].tpl.php but for generating individual bars. profile-wrapper-[field].tpl.php base template: profile-wrapper.tpl.php The profile wrapper template is used when browsing the member listings page. When browsing specific fields, a suggestion is made with the field name. For example, http://drupal.org/profile/country/Belgium would "suggest profile-wrappercountry. tpl.php". search-results-[searchType].tpl.php base template: search-results.tpl.php search-results.tpl.php is the default wrapper for search results. Depending on the type of search different suggestions are made. For example, "example.com/search /node/Search+Term" would result in "searchresults- node.tpl.php" being used. Compare that with "example.com/search/user/bob" resulting in "search-results-user.tpl.php". Modules can extend search types adding more suggestions of their type. search-result-[searchType].tpl.php base template: search-result.tpl.php The same as above but for for individual search results.

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.