- 8.x drupal/core/lib/Drupal/Core/Render/theme.api.php themeable
- 6.x drupal/includes/theme.inc themeable
- 7.x drupal/modules/system/theme.api.php themeable
Functions and templates for the user interface to 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 an array of variables. For example, theme('table', array('header' => $header, 'rows' => $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'), $variables) 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 of hook_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 THEMENAME_HOOK. For example, for Drupal's default theme (Bartik) to implement the 'table' hook, the phptemplate.enginewould find bartik_table().
The theme system is described and defined in theme.inc.
End of "defgroup themeable".
另请参阅
theme()
hook_theme()
Hooks
Callbacks
文件
- drupal/modules/system/theme.api.php, line 3
函数
名字 | 位置 | 描述 | theme_admin_blockdrupal/modules/system/system.admin.incReturns HTML for an administrative block for display.theme_admin_block_contentdrupal/modules/system/system.admin.incReturns HTML for the content of an administrative block.theme_admin_pagedrupal/modules/system/system.admin.incReturns HTML for an administrative page.theme_aggregator_block_itemdrupal/modules/aggregator/aggregator.moduleReturns HTML for an individual feed item for display in the block.theme_aggregator_categorize_itemsdrupal/modules/aggregator/aggregator.pages.incReturns HTML for the aggregator page list form for assigning categories.theme_aggregator_page_opmldrupal/modules/aggregator/aggregator.pages.incPrints the OPML page for the feed.theme_aggregator_page_rssdrupal/modules/aggregator/aggregator.pages.incPrints the RSS page for a feed.theme_authorize_messagedrupal/includes/theme.maintenance.incReturns HTML for a single log message from the authorize.phpbatch operation.theme_authorize_reportdrupal/includes/theme.maintenance.incReturns HTML for a results report of an operation run by authorize.php.theme_book_admin_tabledrupal/modules/book/book.admin.incReturns HTML for a book administration form.theme_book_title_linkdrupal/modules/book/book.moduleReturns HTML for a link to a book title when used as a block title.theme_breadcrumbdrupal/includes/theme.incReturns HTML for a breadcrumb trail.theme_buttondrupal/includes/form.incReturns HTML for a button form element.theme_checkboxdrupal/includes/form.incReturns HTML for a checkbox form element.theme_checkboxesdrupal/includes/form.incReturns HTML for a set of checkbox form elements.theme_color_scheme_formdrupal/modules/color/color.moduleReturns HTML for a theme's color form.theme_comment_blockdrupal/modules/comment/comment.moduleReturns HTML for a list of recent comments to be displayed in the comment block.theme_comment_post_forbiddendrupal/modules/comment/comment.moduleReturns HTML for a "you can't post comments" notice.theme_confirm_formdrupal/modules/system/system.moduleReturns HTML for a confirmation form.theme_containerdrupal/includes/form.incReturns HTML to wrap child elements in a container.theme_dashboarddrupal/modules/dashboard/dashboard.moduleReturns HTML for the entire dashboard.theme_dashboard_admindrupal/modules/dashboard/dashboard.moduleReturns HTML for the non-customizable part of the dashboard page.theme_dashboard_disabled_blockdrupal/modules/dashboard/dashboard.moduleReturns HTML for disabled blocks, for use in dashboard customization mode.theme_dashboard_disabled_blocksdrupal/modules/dashboard/dashboard.moduleReturns HTML for disabled blocks, for use in dashboard customization mode.theme_dashboard_regiondrupal/modules/dashboard/dashboard.moduleReturns HTML for a generic dashboard region.theme_datedrupal/includes/form.incReturns HTML for a date selection form element.theme_dblog_messagedrupal/modules/dblog/dblog.admin.incReturns HTML for a log message.theme_exposed_filtersdrupal/modules/system/system.moduleReturns HTML for an exposed filter form.theme_feed_icondrupal/includes/theme.incReturns HTML for a feed icon.theme_fielddrupal/modules/field/field.moduleReturns HTML for a field.theme_fieldsetdrupal/includes/form.incReturns HTML for a fieldset form element and its children.theme_field_multiple_value_formdrupal/modules/field/field.form.incReturns HTML for an individual form element.theme_field_ui_tabledrupal/modules/field_ui/field_ui.admin.incReturns HTML for Field UI overview tables.theme_filedrupal/includes/form.incReturns HTML for a file upload form element.theme_file_formatter_tabledrupal/modules/file/file.field.incReturns HTML for a file attachments table.theme_file_icondrupal/modules/file/file.moduleReturns HTML for an image with an appropriate icon for the given file.theme_file_linkdrupal/modules/file/file.moduleReturns HTML for a link to a file.theme_file_managed_filedrupal/modules/file/file.moduleReturns HTML for a managed file element.theme_file_upload_helpdrupal/modules/file/file.field.incReturns HTML for help text based on file upload validators.theme_file_widgetdrupal/modules/file/file.field.incReturns HTML for an individual file upload widget.theme_file_widget_multipledrupal/modules/file/file.field.incReturns HTML for a group of file upload widgets.theme_filter_admin_format_filter_orderdrupal/modules/filter/filter.admin.incReturns HTML for a text format's filter order form.theme_filter_admin_overviewdrupal/modules/filter/filter.admin.incReturns HTML for the text format administration overview form.theme_filter_guidelinesdrupal/modules/filter/filter.moduleReturns HTML for guidelines for a text format.theme_filter_tipsdrupal/modules/filter/filter.pages.incReturns HTML for a set of filter tips.theme_filter_tips_more_infodrupal/modules/filter/filter.moduleReturns HTML for a link to the more extensive filter tips.theme_formdrupal/includes/form.incReturns HTML for a form.theme_form_elementdrupal/includes/form.incReturns HTML for a form element.theme_form_element_labeldrupal/includes/form.incReturns HTML for a form element label and required marker.theme_form_required_markerdrupal/includes/form.incReturns HTML for a marker for required form elements.theme_forum_formdrupal/modules/forum/forum.admin.incReturns HTML for a forum form.theme_hiddendrupal/includes/form.incReturns HTML for a hidden form element.theme_html_tagdrupal/includes/theme.incReturns HTML for a generic HTML tag with attributes.theme_imagedrupal/includes/theme.incReturns HTML for an image.theme_image_anchordrupal/modules/image/image.admin.incReturns HTML for a 3x3 grid of checkboxes for image anchors.theme_image_buttondrupal/includes/form.incReturns HTML for an image button form element.theme_image_crop_summarydrupal/modules/image/image.admin.incReturns HTML for a summary of an image crop effect.theme_image_formatterdrupal/modules/image/image.field.incReturns HTML for an image field formatter.theme_image_resize_summarydrupal/modules/image/image.admin.incReturns HTML for a summary of an image resize effect.theme_image_rotate_summarydrupal/modules/image/image.admin.incReturns HTML for a summary of an image rotate effect.theme_image_scale_summarydrupal/modules/image/image.admin.incReturns HTML for a summary of an image scale effect.theme_image_styledrupal/modules/image/image.moduleReturns HTML for an image using a specific image style.theme_image_style_effectsdrupal/modules/image/image.admin.incReturns HTML for a listing of the effects within a specific image style.theme_image_style_listdrupal/modules/image/image.admin.incReturns HTML for the page containing the list of image styles.theme_image_style_previewdrupal/modules/image/image.admin.incReturns HTML for a preview of an image style.theme_image_widgetdrupal/modules/image/image.field.incReturns HTML for an image field widget.theme_indentationdrupal/includes/theme.incReturns HTML for an indentation div; used for drag and drop tables.theme_item_listdrupal/includes/theme.incReturns HTML for a list or nested list of items.theme_linkdrupal/includes/theme.incReturns HTML for a link.theme_linksdrupal/includes/theme.incReturns HTML for a set of links.theme_locale_date_format_formdrupal/modules/locale/locale.admin.incReturns HTML for a locale date format form.theme_locale_languages_configure_formdrupal/modules/locale/locale.admin.incReturns HTML for a language configuration form.theme_locale_languages_overview_formdrupal/modules/locale/locale.admin.incReturns HTML for the language overview form.theme_markdrupal/includes/theme.incReturns HTML for a marker for new or updated content.theme_menu_admin_overviewdrupal/modules/menu/menu.admin.incReturns HTML for a menu title and description for the menu overview page.theme_menu_linkdrupal/includes/menu.incReturns HTML for a menu link and submenu.theme_menu_local_actiondrupal/includes/menu.incReturns HTML for a single local action link.theme_menu_local_taskdrupal/includes/menu.incReturns HTML for a single local task link.theme_menu_local_tasksdrupal/includes/menu.incReturns HTML for primary and secondary local tasks.theme_menu_overview_formdrupal/modules/menu/menu.admin.incReturns HTML for the menu overview form into a table.theme_menu_treedrupal/includes/menu.incReturns HTML for a wrapper for a menu sub-tree.theme_more_help_linkdrupal/includes/theme.incReturns HTML for a "more help" link.theme_more_linkdrupal/includes/theme.incReturns HTML for a "more" link, like those used in blocks.theme_node_add_listdrupal/modules/node/node.pages.incReturns HTML for a list of available node types for node creation.theme_node_admin_overviewdrupal/modules/node/content_types.incReturns HTML for a node type description for the content type admin overview page.theme_node_previewdrupal/modules/node/node.pages.incReturns HTML for a node preview for display during node creation and editing.theme_node_recent_blockdrupal/modules/node/node.moduleReturns HTML for a list of recent content.theme_node_recent_contentdrupal/modules/node/node.moduleReturns HTML for a recent node to be displayed in the recent content block.theme_node_search_admindrupal/modules/node/node.moduleReturns HTML for the content ranking part of the search settings admin page.theme_options_nonedrupal/modules/field/modules/options/options.moduleReturns HTML for the label for the empty value for options that are not required.theme_overlay_disable_messagedrupal/modules/overlay/overlay.moduleReturns the HTML for the message about how to disable the overlay.theme_pagerdrupal/includes/