国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

[Drupal教程] Drupal的组成部分 8.主题(模板)系统

[复制链接]
发表于 11-29-2011 07:38 | 显示全部楼层 |阅读模式

Functions and templates that present output to the user, and can be implemented by themes.

Drupal's presentation layer is a pluggable system known as the theme layer. Each theme can take control over most of Drupal's output, and has complete control over the CSS.

Inside Drupal, the theme layer is utilized by the use of the theme() function, which is passed the name of a component (the theme hook) and several arguments. For example, theme('table', $header, $rows); Additionally, the theme() function can take an array of theme hooks, which can be used to provide 'fallback' implementations to allow for more specific control of output. For example, the function:theme(array('table__foo', 'table'), $header, $rows) would look to see if 'table__foo' is registered anywhere; if it is not, it would 'fall back' to the generic 'table' implementation. This can be used to attach specific theme functions to named objects, allowing the themer more control over specific types of output.

As of Drupal 6, every theme hook is required to be registered by the module that owns it, so that Drupal can tell what to do with it and to make it simple for themes to identify and override the behavior for these calls.

The theme hooks are registered via hook_theme(), which returns an array of arrays with information about the hook. It describes the arguments the function or template will need, and provides defaults for the template in case they are not filled in. If the default implementation is a function, by convention it is named theme_HOOK().

Each module should provide a default implementation for theme_hooks that it registers. This implementation may be either a function or a template; if it is a function it must be specified via hook_theme(). By convention, default implementations of theme hooks are named theme_HOOK. Default template implementations are stored in the module directory.

Drupal's default template renderer is a simple PHP parsing engine that includes the template and stores the output. Drupal's theme engines can provide alternate template engines, such as XTemplate, Smarty and PHPTal. The most common template engine is PHPTemplate (included with Drupal and implemented in phptemplate.engine, which uses Drupal's default template renderer.

In order to create theme-specific implementations of these hooks, themes can implement their own version of theme hooks, either as functions or templates. These implementations will be used instead of the default implementation. If using a pure .theme without an engine, the .theme is required to implement its own version ofhook_theme() to tell Drupal what it is implementing; themes utilizing an engine will have their well-named theming functions automatically registered for them. While this can vary based upon the theme engine, the standard set by phptemplate is that theme functions should be named either phptemplate_HOOK or THEMENAME_HOOK. For example, for Drupal's default theme (Garland) to implement the 'table' hook, thephptemplate.engine would find phptemplate_table() or garland_table(). The ENGINE_HOOK() syntax is preferred, as this can be used by sub-themes (which are themes that share code but use different stylesheets).

The theme system is described and defined in theme.inc.

See also

theme()

@see hook_theme()

函数

名称sort icon位置描述
theme_admin_blockmodules/system/system.admin.incThis function formats an administrative block for display.
theme_admin_block_contentmodules/system/system.admin.incThis function formats the content of an administrative block.
theme_admin_pagemodules/system/system.admin.incThis function formats an administrative page for viewing.
theme_aggregator_page_opmlmodules/aggregator/aggregator.pages.incTheme the OPML feed output.
theme_aggregator_page_rssmodules/aggregator/aggregator.pages.incTheme the RSS output.
theme_blocksincludes/theme.incReturn a set of blocks available for the current user.
theme_book_admin_tablemodules/book/book.admin.incTheme function for the book administration page form. See alsobook_admin_table()
theme_book_title_linkmodules/book/book.moduleGenerate the HTML output for a link to a book title when used as a block title.
theme_boxincludes/theme.incReturn a themed box.
theme_breadcrumbincludes/theme.incReturn a themed breadcrumb trail.
theme_buttonincludes/form.incTheme a form button.
theme_checkboxincludes/form.incFormat a checkbox.
theme_checkboxesincludes/form.incFormat a set of checkboxes.
theme_closureincludes/theme.incExecute hook_footer() which is run at the end of the page right before the close of the body tag.
theme_comment_admin_overviewmodules/comment/comment.admin.incTheme the comment admin form.
theme_comment_flat_collapsedmodules/comment/comment.moduleTheme comment flat collapsed view.
theme_comment_flat_expandedmodules/comment/comment.moduleTheme comment flat expanded view.
theme_comment_post_forbiddenmodules/comment/comment.moduleTheme a "you can't post comments" notice.
theme_comment_submittedmodules/comment/comment.moduleTheme a "Submitted by ..." notice.
theme_comment_thread_collapsedmodules/comment/comment.moduleTheme comment thread collapsed view.
theme_comment_thread_expandedmodules/comment/comment.moduleTheme comment thread expanded view.
theme_comment_viewmodules/comment/comment.moduleTheme a single comment block.
theme_dateincludes/form.incFormat a date selection element.
theme_dblog_filtersmodules/dblog/dblog.moduleTheme dblog administration filter selector.
theme_feed_iconincludes/theme.incReturn code that emits an feed icon.
theme_fieldsetincludes/form.incFormat a group of form items.
theme_fileincludes/form.incFormat a file upload field.
theme_filter_admin_ordermodules/filter/filter.admin.incTheme filter order configuration form.
theme_filter_admin_overviewmodules/filter/filter.admin.incTheme the admin overview form.
theme_filter_tipsmodules/filter/filter.pages.incRender HTML for a set of filter tips.
theme_filter_tips_more_infomodules/filter/filter.moduleFormat a link to the more extensive filter tips.
theme_formincludes/form.incFormat a form.
theme_form_elementincludes/form.incReturn a themed form element.
theme_helpincludes/theme.incReturn a themed help message.
theme_hiddenincludes/form.incFormat a hidden form field.
theme_imageincludes/theme.incReturn a themed image.
theme_image_buttonincludes/form.incTheme a form image button.
theme_indentationincludes/theme.incCreate a standard indentation div. Used for drag and drop tables.
theme_itemincludes/form.incFormat a form item.
theme_item_listincludes/theme.incReturn a themed list of items.
theme_linksincludes/theme.incReturn a themed set of links.
theme_locale_languages_overview_formincludes/locale.incTheme the language overview form.
theme_markincludes/theme.incReturn a themed marker, useful for marking new or updated content.
theme_menu_itemincludes/menu.incGenerate the HTML output for a menu item and submenu.
theme_menu_item_linkincludes/menu.incGenerate the HTML output for a single menu link.
theme_menu_local_taskincludes/menu.incGenerate the HTML output for a single local task link.
theme_menu_local_tasksincludes/menu.incReturns the rendered local tasks. The default implementation renders them as tabs.
theme_menu_overview_formmodules/menu/menu.admin.incTheme the menu overview form into a table.
theme_menu_treeincludes/menu.incGenerate the HTML output for a menu tree
theme_meta_generator_headermodules/system/system.moduleSend Drupal and the major version number in the HTTP headers.
theme_meta_generator_htmlmodules/system/system.moduleSend Drupal and the major version number in the META GENERATOR HTML.
theme_more_help_linkincludes/theme.incReturns code that emits the 'more help'-link.
theme_more_linkincludes/theme.incReturns code that emits the 'more' link used on blocks.
theme_node_add_listmodules/node/node.pages.incDisplay the list of available node types for node creation.
theme_node_admin_nodesmodules/node/node.admin.incTheme node administration overview.
theme_node_filtersmodules/node/node.admin.incTheme node administration filter selector.
theme_node_filter_formmodules/node/node.admin.incTheme node administration filter form.
theme_node_formmodules/node/node.pages.incPresent a node submission form.
theme_node_linksmodules/node/node.moduleFormat a set of node links.
theme_node_listmodules/node/node.moduleFormat a listing of links to nodes.
theme_node_log_messagemodules/node/node.moduleTheme a log message.
theme_node_previewmodules/node/node.pages.incDisplay a node preview for display during node creation and editing.
theme_node_search_adminmodules/node/node.moduleTheme the content ranking part of the search settings admin page.
theme_node_submittedmodules/node/node.moduleFormat the "Submitted by username on date/time" for each node
theme_pagerincludes/pager.incFormat a query pager.
theme_pager_firstincludes/pager.incFormat a "first page" link.
theme_pager_lastincludes/pager.incFormat a "last page" link.
theme_pager_linkincludes/pager.incFormat a link to a specific query result page.
theme_pager_nextincludes/pager.incFormat a "next page" link.
theme_pager_previousincludes/pager.incFormat a "previous page" link.
theme_passwordincludes/form.incFormat a password field.
theme_password_confirmincludes/form.incFormat a password_confirm item.
theme_placeholderincludes/theme.incFormats text for emphasized display in a placeholder inside a sentence. Used automatically by t().
theme_poll_choicesmodules/poll/poll.moduleTheme the admin poll form for choices.
theme_profile_admin_overviewmodules/profile/profile.admin.incTheme the profile field overview into a drag and drop enabled table. See alsoprofile_admin_overview()
theme_progress_barincludes/theme.incReturn a themed progress bar.
theme_radioincludes/form.incFormat a radio button.
theme_radiosincludes/form.incFormat a set of radio buttons.
theme_scaffolding_example_overview_formdeveloper/examples/scaffolding_example/scaffolding_example.admin.incTheme the drag-and-drop overview form.
theme_scaffolding_example_recorddeveloper/examples/scaffolding_example/scaffolding_example.pages.incTheme a single record.
theme_selectincludes/form.incFormat a dropdown menu or scrolling selection box.
theme_status_messagesincludes/theme.incReturn a themed set of status and/or error messages. The messages are grouped by type.
theme_status_reportmodules/system/system.admin.incTheme requirements status report.
theme_submenuincludes/theme.incReturn a themed submenu, typically displayed under the tabs.
theme_submitincludes/form.incTheme a form submit button.
theme_syslog_formatmodules/syslog/syslog.moduleFormat a system log entry.
theme_system_admin_by_modulemodules/system/system.admin.incTheme output of the dashboard page.
theme_system_compact_linkmodules/system/system.moduleDisplay the link to show or hide inline help descriptions.
theme_system_modules_fieldsetmodules/system/system.admin.incTheme callback for the modules form.
theme_system_modules_incompatiblemodules/system/system.admin.incThemes an incompatible message.
theme_system_modules_uninstallmodules/system/system.admin.incThemes a table of currently disabled modules.
theme_system_powered_bymodules/system/system.moduleFormat the Powered by Drupal text.
theme_system_themes_formmodules/system/system.admin.incTheme function for the system themes form.
theme_system_theme_select_formmodules/system/system.admin.incTheme the theme select form.
theme_tableincludes/theme.incReturn a themed table.
theme_tablesort_indicatorincludes/theme.incReturn a themed sort icon.
theme_table_select_header_cellincludes/theme.incReturns a header cell for tables that have a select all functionality.
theme_task_listincludes/theme.maintenance.incReturn a themed list of maintenance tasks to perform.
theme_taxonomy_overview_termsmodules/taxonomy/taxonomy.admin.incTheme the terms overview as a sortable list of terms. See alsotaxonomy_overview_terms()
theme_taxonomy_overview_vocabulariesmodules/taxonomy/taxonomy.admin.incTheme the vocabulary overview as a sortable list of vocabularies. See alsotaxonomy_overview_vocabularies()
theme_taxonomy_term_pagemodules/taxonomy/taxonomy.pages.incRender a taxonomy term page HTML output.
theme_taxonomy_term_selectmodules/taxonomy/taxonomy.moduleFormat the selection field for choosing terms (by default the default selection field is used).
theme_textareaincludes/form.incFormat a textarea.
theme_textfieldincludes/form.incFormat a textfield.
theme_tokenincludes/form.incFormat a form token.
theme_trigger_displaymodules/trigger/trigger.admin.incDisplay actions assigned to this hook-op combination in a table.
theme_update_reportmodules/update/update.report.incTheme project status report.
theme_update_versionmodules/update/update.report.incTheme the version display of a project.
theme_upload_attachmentsmodules/upload/upload.moduleDisplays file attachments in table
theme_upload_form_currentmodules/upload/upload.moduleTheme the attachments list.
theme_upload_form_newmodules/upload/upload.moduleTheme the attachment form. Note: required to output prefix/suffix.
theme_usernameincludes/theme.incFormat a username.
theme_user_admin_accountmodules/user/user.admin.incTheme user administration overview.
theme_user_admin_new_rolemodules/user/user.admin.incTheme the new-role form.
theme_user_admin_permmodules/user/user.admin.incTheme the administer permissions page.
theme_user_filtersmodules/user/user.admin.incTheme user administration filter selector.
theme_user_filter_formmodules/user/user.admin.incTheme user administration filter form.
theme_user_listmodules/user/user.moduleMake a list of users.
theme_user_signaturemodules/user/user.moduleTheme output of user signature.
theme_xml_iconincludes/theme.incReturn code that emits an XML icon.

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 3-15-2025 01:02 , Processed in 0.409126 second(s), 237 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表