Default theme implementations

  1. drupal
    1. 5
    2. 8
    3. 6
    4. 7

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.engine would find bartik_table().

The theme system is described and defined in

End of "defgroup themeable".

See also



Functions & methods

theme_admin_blockReturns HTML for an administrative block for display.
theme_admin_block_contentReturns HTML for the content of an administrative block.
theme_admin_pageReturns HTML for an administrative page.
theme_aggregator_block_itemReturns HTML for an individual feed item for display in the block.
theme_aggregator_categorize_itemsReturns HTML for the aggregator page list form for assigning categories.
theme_aggregator_feed_sourceImplemented using the aggregator-feed-source.tpl.php template.
theme_aggregator_itemImplemented using the aggregator-item.tpl.php template.
theme_aggregator_page_opmlPrints the OPML page for a feed.
theme_aggregator_page_rssPrints the RSS page for a feed.
theme_aggregator_summary_itemImplemented using the aggregator-summary-item.tpl.php template.
theme_aggregator_summary_itemsImplemented using the aggregator-summary-items.tpl.php template.
theme_aggregator_wrapperImplemented using the aggregator-wrapper.tpl.php template.
theme_authorize_messageReturns HTML for a single log message from the authorize.php batch operation.
theme_authorize_reportReturns HTML for a report of the results from an operation run via authorize.php.
theme_blockImplemented using the block.tpl.php template.
theme_block_admin_display_formImplemented using the block-admin-display-form.tpl.php template.
theme_book_admin_tableReturns HTML for a book administration form.
theme_book_all_books_blockImplemented using the book-all-books-block.tpl.php template.
theme_book_export_htmlImplemented using the book-export-html.tpl.php template.
theme_book_navigationImplemented using the book-navigation.tpl.php template.
theme_book_node_export_htmlImplemented using the book-node-export-html.tpl.php template.
theme_book_title_linkReturns HTML for a link to a book title when used as a block title.
theme_breadcrumbReturns HTML for a breadcrumb trail.
theme_buttonReturns HTML for a button form element.
theme_checkboxReturns HTML for a checkbox form element.
theme_checkboxesReturns HTML for a set of checkbox form elements.
theme_color_scheme_formReturns HTML for a theme's color form.
theme_commentImplemented using the comment.tpl.php template.
theme_comment_blockReturns HTML for a list of recent comments to be displayed in the comment block.
theme_comment_post_forbiddenReturns HTML for a "you can't post comments" notice.
theme_comment_wrapperImplemented using the comment-wrapper.tpl.php template.
theme_confirm_formReturns HTML for a confirmation form.
theme_containerReturns HTML to wrap child elements in a container.
theme_dashboardReturns HTML for the entire dashboard.
theme_dashboard_adminReturns HTML for the non-customizable part of the dashboard page.
theme_dashboard_disabled_blockReturns HTML for a disabled block, for display in dashboard customization mode.
theme_dashboard_disabled_blocksReturns HTML for a set of disabled blocks, for display in dashboard customization mode.
theme_dashboard_regionReturns HTML for a generic dashboard region.
theme_dateReturns HTML for a date selection form element.
theme_dblog_messageReturns HTML for a log message.
theme_exposed_filtersReturns HTML for an exposed filter form.
theme_feed_iconReturns HTML for a feed icon.
theme_fieldReturns HTML for a field.
theme_fieldImplemented using the field.tpl.php template.
theme_fieldsetReturns HTML for a fieldset form element and its children.
theme_field_multiple_value_formReturns HTML for an individual form element.
theme_field_ui_display_overview_tableImplemented using the field_ui-display-overview-table.tpl.php template.
theme_field_ui_field_overview_formImplemented using the field_ui-field-overview-form.tpl.php template.
theme_field_ui_tableReturns HTML for Field UI overview tables.
theme_fileReturns HTML for a file upload form element.
theme_file_formatter_tableReturns HTML for a file attachments table.
theme_file_iconReturns HTML for an image with an appropriate icon for the given file.
theme_file_linkReturns HTML for a link to a file.
theme_file_managed_fileReturns HTML for a managed file element.
theme_file_upload_helpReturns HTML for help text based on file upload validators.
theme_file_widgetReturns HTML for an individual file upload widget.
theme_file_widget_multipleReturns HTML for a group of file upload widgets.
theme_filter_admin_format_filter_orderReturns HTML for a text format's filter order form.
theme_filter_admin_overviewReturns HTML for the text format administration overview form.
theme_filter_guidelinesReturns HTML for guidelines for a text format.
theme_filter_tipsReturns HTML for a set of filter tips.
theme_filter_tips_more_infoReturns HTML for a link to the more extensive filter tips.
theme_formReturns HTML for a form.
theme_form_elementReturns HTML for a form element.
theme_form_element_labelReturns HTML for a form element label and required marker.
theme_form_required_markerReturns HTML for a marker for required form elements.
theme_forumsImplemented using the forums.tpl.php template.
theme_forum_formReturns HTML for a forum form.
theme_forum_iconImplemented using the forum-icon.tpl.php template.
theme_forum_listImplemented using the forum-list.tpl.php template.
theme_forum_submittedImplemented using the forum-submitted.tpl.php template.
theme_forum_topic_listImplemented using the forum-topic-list.tpl.php template.
theme_hiddenReturns HTML for a hidden form element.
theme_htmlImplemented using the html.tpl.php template.
theme_html_tagReturns HTML for a generic HTML tag with attributes.
theme_imageReturns HTML for an image.
theme_image_anchorReturns HTML for a 3x3 grid of checkboxes for image anchors.
theme_image_buttonReturns HTML for an image button form element.
theme_image_crop_summaryReturns HTML for a summary of an image crop effect.
theme_image_formatterReturns HTML for an image field formatter.
theme_image_resize_summaryReturns HTML for a summary of an image resize effect.
theme_image_rotate_summaryReturns HTML for a summary of an image rotate effect.
theme_image_scale_summaryReturns HTML for a summary of an image scale effect.
theme_image_styleReturns HTML for an image using a specific image style.
theme_image_style_effectsReturns HTML for a listing of the effects within a specific image style.
theme_image_style_listReturns HTML for the page containing the list of image styles.
theme_image_style_previewReturns HTML for a preview of an image style.
theme_image_widgetReturns HTML for an image field widget.
theme_indentationReturns HTML for an indentation div; used for drag and drop tables.
theme_item_listReturns HTML for a list or nested list of items.
theme_linkReturns HTML for a link.
theme_linksReturns HTML for a set of links.
theme_locale_date_format_formReturns HTML for a locale date format form.
theme_locale_languages_configure_formReturns HTML for a language configuration form.
theme_locale_languages_overview_formReturns HTML for the language overview form.
theme_maintenance_pageImplemented using the maintenance-page.tpl.php template.
theme_markReturns HTML for a marker for new or updated content.
theme_menu_admin_overviewReturns HTML for a menu title and description for the menu overview page.
theme_menu_linkReturns HTML for a menu link and submenu.
theme_menu_local_actionReturns HTML for a single local action link.
theme_menu_local_taskReturns HTML for a single local task link.
theme_menu_local_tasksReturns HTML for primary and secondary local tasks.
theme_menu_overview_formReturns HTML for the menu overview form into a table.
theme_menu_treeReturns HTML for a wrapper for a menu sub-tree.
theme_more_help_linkReturns HTML for a "more help" link.
theme_more_linkReturns HTML for a "more" link, like those used in blocks.
theme_nodeImplemented using the node.tpl.php template.
theme_node_add_listReturns HTML for a list of available node types for node creation.
theme_node_admin_overviewReturns HTML for a node type description for the content type admin overview page.
theme_node_previewReturns HTML for a node preview for display during node creation and editing.
theme_node_recent_blockReturns HTML for a list of recent content.
theme_node_recent_contentReturns HTML for a recent node to be displayed in the recent content block.
theme_node_search_adminReturns HTML for the content ranking part of the search settings admin page.
theme_options_noneReturns HTML for the label for the empty value for options that are not required.
theme_pageImplemented using the page.tpl.php template.
theme_pagerReturns HTML for a query pager.
theme_pager_firstReturns HTML for the "first page" link in a query pager.
theme_pager_lastReturns HTML for the "last page" link in query pager.
theme_pager_linkReturns HTML for a link to a specific query result page.
theme_pager_nextReturns HTML for the "next page" link in a query pager.
theme_pager_previousReturns HTML for the "previous page" link in a query pager.
theme_passwordReturns HTML for a password form element.
theme_poll_barImplemented using the poll-bar.tpl.php template.
theme_poll_bar__blockImplemented using the poll-bar--block.tpl.php template.
theme_poll_choicesReturns HTML for an admin poll form for choices.
theme_poll_resultsImplemented using the poll-results.tpl.php template.
theme_poll_results__blockImplemented using the poll-results--block.tpl.php template.
theme_poll_voteImplemented using the poll-vote.tpl.php template.
theme_profile_admin_overviewReturns HTML for the profile field overview form into a drag and drop enabled table.
theme_profile_blockImplemented using the profile-block.tpl.php template.
theme_profile_listingImplemented using the profile-listing.tpl.php template.
theme_profile_wrapperImplemented using the profile-wrapper.tpl.php template.
theme_progress_barReturns HTML for a progress bar.
theme_radioReturns HTML for a radio button form element.
theme_radiosReturns HTML for a set of radio button form elements.
theme_rdf_metadataReturns HTML for a series of empty spans for exporting RDF metadata in RDFa.
theme_rdf_template_variable_wrapperReturns HTML for a template variable wrapped in an HTML element with the RDF attributes.
theme_regionImplemented using the region.tpl.php template.
theme_search_block_formImplemented using the search-block-form.tpl.php template.
theme_search_resultImplemented using the search-result.tpl.php template.
theme_search_resultsImplemented using the search-results.tpl.php template.
theme_selectReturns HTML for a select form element.
theme_shortcut_set_customizeReturns HTML for a shortcut set customization form.
theme_simpletest_result_summaryReturns HTML for the summary status of a simpletest result.
theme_simpletest_test_tableReturns HTML for a test list generated by simpletest_test_form() into a table.
theme_status_messagesReturns HTML for status and/or error messages, grouped by type.
theme_status_reportReturns HTML for the status report.
theme_submitReturns HTML for a submit button form element.
theme_system_admin_indexReturns HTML for the output of the dashboard page.
theme_system_compact_linkReturns HTML for a link to show or hide inline help descriptions.
theme_system_date_time_settingsReturns HTML for the date settings form.
theme_system_modules_fieldsetReturns HTML for the modules form.
theme_system_modules_incompatibleReturns HTML for a message about incompatible modules.
theme_system_modules_uninstallReturns HTML for a table of currently disabled modules.
theme_system_powered_byReturns HTML for the Powered by Drupal text.
theme_system_settings_formReturns HTML for a system settings form.
theme_system_themes_pageReturns HTML for the Appearance page.
theme_tableReturns HTML for a table.
theme_tableselectReturns HTML for a table with radio buttons or checkboxes.
theme_tablesort_indicatorReturns HTML for a sort icon.
theme_task_listReturns HTML for a list of maintenance tasks to perform.
theme_taxonomy_overview_termsReturns HTML for a terms overview form as a sortable list of terms.
theme_taxonomy_overview_vocabulariesReturns HTML for the vocabulary overview form as a sortable list of vocabularies.
theme_taxonomy_termImplemented using the taxonomy-term.tpl.php template.
theme_textareaReturns HTML for a textarea form element.
theme_textfieldReturns HTML for a textfield form element.
theme_text_format_wrapperReturns HTML for a text format-enabled form element.
theme_toolbarImplemented using the toolbar.tpl.php template.
theme_trigger_displayReturns HTML for the form showing actions assigned to a trigger.
theme_update_last_checkReturns HTML for the last time we checked for update data.
theme_update_manager_update_formReturns HTML for the first page in the update manager wizard to select projects.
theme_update_reportReturns HTML for the project status report.
theme_update_versionReturns HTML for the version display of a project.
theme_usernameReturns HTML for a username, potentially linked to the user's page.
theme_user_admin_permissionsReturns HTML for the administer permissions page.
theme_user_admin_rolesReturns HTML for the role order and new role form.
theme_user_listReturns HTML for a list of users.
theme_user_permission_descriptionReturns HTML for an individual permission description.
theme_user_pictureImplemented using the user-picture.tpl.php template.
theme_user_profileImplemented using the user-profile.tpl.php template.
theme_user_profile_categoryImplemented using the user-profile-category.tpl.php template.
theme_user_profile_itemImplemented using the user-profile-item.tpl.php template.
theme_user_signatureReturns HTML for a user signature.
theme_vertical_tabsReturns HTML for an element's children fieldsets as vertical tabs.

modules/system/theme.api.php, line 3