Skip navigation

Default theme implementations

  1. drupal
    1. 6 drupal/includes/
    2. 7 drupal/modules/system/theme.api.php

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 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 either phptemplate_HOOK or THEMENAME_HOOK. For example, for Drupal's default theme (Garland) to implement the 'table' hook, the phptemplate.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

See also




drupal/includes/theme.incThe theme system, which controls the output of Drupal.

Functions & methods

phptemplate_menu_local_tasksReturns the rendered local tasks. The default implementation renders them as tabs. Overridden to split the secondary tasks.
theme_address_paneThemes the delivery/billing address forms in tables.
theme_admin_blockThis function formats an administrative block for display.
theme_admin_block_contentThis function formats the content of an administrative block.
theme_admin_pageThis function formats an administrative page for viewing.
theme_aggregator_block_itemFormat an individual feed item for display in the block.
theme_aggregator_categorize_itemsTheme the 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_opmlTheme the OPML feed output.
theme_aggregator_page_rssTheme the RSS output.
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_blockImplemented using the block.tpl.php template.
theme_blocksReturn a set of blocks available for the current user.
theme_block_admin_display_formImplemented using the block-admin-display-form.tpl.php template.
theme_book_admin_tableTheme function for the book administration page 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_linkGenerate the HTML output for a link to a book title when used as a block title.
theme_boxReturn a themed box.
theme_breadcrumbReturn a themed breadcrumb trail.
theme_buttonTheme a form button.
theme_cart_review_tableFormats the cart contents table on the checkout page.
theme_checkboxFormat a checkbox.
theme_checkboxesFormat a set of checkboxes.
theme_closureExecute hook_footer() which is run at the end of the page right before the close of the body tag.
theme_color_scheme_formTheme color form.
theme_commentImplemented using the comment.tpl.php template.
theme_comment_admin_overviewTheme the comment admin form.
theme_comment_blockReturns a formatted list of recent comments to be displayed in the comment block.
theme_comment_controlsTheme comment controls box where the user can change the default display mode and display order of comments.
theme_comment_flat_collapsedTheme comment flat collapsed view.
theme_comment_flat_expandedTheme comment flat expanded view.
theme_comment_foldedImplemented using the comment-folded.tpl.php template.
theme_comment_post_forbiddenTheme a "you can't post comments" notice.
theme_comment_submittedTheme a "Submitted by ..." notice.
theme_comment_thread_collapsedTheme comment thread collapsed view.
theme_comment_thread_expandedTheme comment thread expanded view.
theme_comment_viewThemes a single comment and related items.
theme_comment_wrapperImplemented using the comment-wrapper.tpl.php template.
theme_dateFormat a date selection element.
theme_dblog_filtersTheme dblog administration filter selector.
theme_feed_iconReturn code that emits an feed icon.
theme_fieldsetFormat a group of form items.
theme_fileFormat a file upload field.
theme_filter_admin_orderTheme filter order configuration form.
theme_filter_admin_overviewTheme the admin overview form.
theme_filter_tipsFormat a set of filter tips.
theme_filter_tips_more_infoFormat a link to the more extensive filter tips.
theme_formFormat a form.
theme_form_elementReturn a themed form element.
theme_forumsImplemented using the forums.tpl.php template.
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_forum_topic_navigationImplemented using the forum-topic-navigation.tpl.php template.
theme_helpReturn a themed help message.
theme_hiddenFormat a hidden form field.
theme_imageReturn a themed image.
theme_image_buttonTheme a form image button.
theme_indentationCreate a standard indentation div. Used for drag and drop tables.
theme_itemFormat a form item.
theme_item_listReturn a themed list of items.
theme_linksReturn a themed set of links.
theme_locale_languages_overview_formTheme the language overview form.
theme_maintenance_pageImplemented using the maintenance-page.tpl.php template.
theme_markReturn a themed marker, useful for marking new or updated content.
theme_menu_itemGenerate the HTML output for a menu item and submenu.
theme_menu_item_linkGenerate the HTML output for a single menu link.
theme_menu_local_taskGenerate the HTML output for a single local task link.
theme_menu_local_tasksReturns the rendered local tasks. The default implementation renders them as tabs.
theme_menu_overview_formTheme the menu overview form into a table.
theme_menu_treeGenerate the HTML output for a menu tree
theme_more_help_linkReturns code that emits the 'more help'-link.
theme_more_linkReturns code that emits the 'more' link used on blocks.
theme_nodeImplemented using the node.tpl.php template.
theme_node_add_listDisplay the list of available node types for node creation.
theme_node_admin_nodesTheme node administration overview.
theme_node_filtersTheme node administration filter selector.
theme_node_filter_formTheme node administration filter form.
theme_node_formPresent a node submission form.
theme_node_listFormat a listing of links to nodes.
theme_node_log_messageTheme a log message.
theme_node_previewDisplay a node preview for display during node creation and editing.
theme_node_search_adminTheme the content ranking part of the search settings admin page.
theme_node_submittedFormat the "Submitted by username on date/time" for each node
theme_pageImplemented using the page.tpl.php template.
theme_pagerFormat a query pager.
theme_pager_firstFormat a "first page" link.
theme_pager_lastFormat a "last page" link.
theme_pager_linkFormat a link to a specific query result page.
theme_pager_nextFormat a "next page" link.
theme_pager_previousFormat a "previous page" link.
theme_passwordFormat a password field.
theme_password_confirmFormat a password_confirm item.
theme_placeholderFormats text for emphasized display in a placeholder inside a sentence. Used automatically by t().
theme_poll_barImplemented using the poll-bar.tpl.php template.
theme_poll_bar_blockImplemented using the poll-bar-block.tpl.php template.
theme_poll_choicesTheme the 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_overviewTheme the profile field overview 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_barReturn a themed progress bar.
theme_radioFormat a radio button.
theme_radiosFormat a set of radio buttons.
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_search_theme_formImplemented using the search-theme-form.tpl.php template.
theme_selectFormat a dropdown menu or scrolling selection box.
theme_status_messagesReturn a themed set of status and/or error messages. The messages are grouped by type.
theme_status_reportTheme requirements status report.
theme_submenuReturn a themed submenu, typically displayed under the tabs.
theme_submitTheme a form submit button.
theme_summary_overviewTheme a summaries array into a handy div for use with some JS enhancement.
theme_syslog_formatFormat a system log entry.
theme_system_admin_by_moduleTheme output of the dashboard page.
theme_system_modulesTheme callback for the modules form.
theme_system_modules_uninstallThemes a table of currently disabled modules.
theme_system_powered_byFormat the Powered by Drupal text.
theme_system_themes_formTheme function for the system themes form.
theme_system_theme_select_formTheme the theme select form.
theme_tableReturn a themed table.
theme_tablesort_indicatorReturn a themed sort icon.
theme_table_select_header_cellReturns a header cell for tables that have a select all functionality.
theme_tapir_tableThemes form data into a table for display.
theme_task_listReturn a themed list of maintenance tasks to perform.
theme_taxonomy_overview_termsTheme the terms overview as a sortable list of terms.
theme_taxonomy_overview_vocabulariesTheme the vocabulary overview as a sortable list of vocabularies.
theme_taxonomy_term_pageRender a taxonomy term page HTML output.
theme_taxonomy_term_selectFormat the selection field for choosing terms (by deafult the default selection field is used).
theme_textareaFormat a textarea.
theme_textfieldFormat a textfield.
theme_tokenFormat a form token.
theme_token_helpFor a given context, builds a formatted list of tokens and descriptions of their replacement values.
theme_token_treeProvide a 'tree' display of nested tokens.
theme_trigger_displayDisplay actions assigned to this hook-op combination in a table.
theme_uc_admin_dashboardThemes the dashboard on the admin/store page.
theme_uc_attribute_add_to_cartDisplays the attribute selection form elements.
theme_uc_attribute_bulk_update_formDisplays the bulk product update form.
theme_uc_attribute_optionDisplays an attribute option with an optional total or adjustment price.
theme_uc_attribute_options_formFormats an attribute and its options.
theme_uc_cart_block_contentThemes the shopping cart block content.
theme_uc_cart_block_content_cachableThemes the cachable shopping cart block content.
theme_uc_cart_block_itemsThemes the table listing the items in the shopping cart block.
theme_uc_cart_block_summaryThemes the summary table at the bottom of the default shopping cart block.
theme_uc_cart_block_titleThemes the shopping cart block title
theme_uc_cart_block_title_iconThemes the shopping cart icon.
theme_uc_cart_checkout_formAdds markup and styling to the checkout panes.
theme_uc_cart_checkout_reviewThemes the checkout review order page.
theme_uc_cart_complete_saleThemes the sale completion page.
theme_uc_cart_pane_quotesDisplays the formatted quote cart pane.
theme_uc_cart_view_formThemes the uc_cart_view_form().
theme_uc_cart_view_priceDumb wrapper function, as the price has been themed by uc_price() already.
theme_uc_catalog_blockThemes the catalog block.
theme_uc_catalog_browseDisplay a formatted catalog page.
theme_uc_catalog_itemDisplays a formatted link in the catalog block.
theme_uc_catalog_productsDisplays a formatted list of products.
theme_uc_catalog_product_gridDisplays a list of products in grid format().
theme_uc_checkout_pane_cart_reviewThemes cart items on the checkout review order page.
theme_uc_empty_cartReturns the text displayed for an empty shopping cart.
theme_uc_file_admin_files_form_showReturns HTML for uc_file_admin_files_form_show().
theme_uc_file_downloads_tokenThemes file download links token.
theme_uc_file_hook_user_file_downloadsThemes the download table at the user account page.
theme_uc_file_user_downloadsThemes user file downloads page.
theme_uc_object_attributes_formDisplays the formatted attribute form.
theme_uc_object_options_formDisplays the option form.
theme_uc_order_edit_formFormats the uc_order_edit_form().
theme_uc_order_remove_productFormats the button to remove products from an order.
theme_uc_order_state_tableTheme the order state table in the order workflow settings.
theme_uc_pane_sort_tableThemes a pane sorting form into a table.
theme_uc_payment_by_order_formThemes uc_payment_by_order_form().
theme_uc_payment_method_other_formTheme function for uc_payment_method_other_form().
theme_uc_payment_method_tableThemes the table that displays available payment methods.
theme_uc_payment_pack_receive_check_formThemes the receive check form.
theme_uc_payment_totalsGenerates markup for payment totals.
theme_uc_priceThemes a formatted price for display.
theme_uc_price_settings_formRenders the price handler form, adding tabledrag.
theme_uc_product_add_to_cartWraps the "Add to Cart" form in a <div>.
theme_uc_product_bodyFormats a product's body.
theme_uc_product_dimensionsFormats a product's length, width, and height.
theme_uc_product_dimensions_formPuts length, width, and height fields on the same line.
theme_uc_product_feature_add_formTheme function for uc_product_feature_add_form().
theme_uc_product_field_settings_formDisplays the product field settings form.
theme_uc_product_form_pricesFormats product price fields for node/%/edit form.
theme_uc_product_form_weightFormats product weight fields for node/%/edit form.
theme_uc_product_imageFormats a product's images.
theme_uc_product_kit_add_to_cartWraps the "Add to Cart" form in a <div>.
theme_uc_product_kit_list_itemRenders a product kit component.
theme_uc_product_modelFormats a product's model number.
theme_uc_product_priceFormats a product's price.
theme_uc_product_weightFormats a product's weight.
theme_uc_quote_method_settingsDisplays a formatted list of shipping quote methods and form elements.
theme_uc_reports_product_tableReturn a themed table for product reports.
theme_uc_roles_expirationThemes user role expiration page.
theme_uc_roles_user_expirationThemes the role expiration table within the roles dialog on the account edit page.
theme_uc_shipping_addressCompact the address into a table.
theme_uc_shipping_edit_package_fieldsetDisplays a formatted shipping type fieldset.
theme_uc_shipping_new_package_fieldsetFormats and displays the products in a shipping type fieldset.
theme_uc_shipping_new_shipmentFormats and displays the new shipment form.
theme_uc_shipping_package_dimensionsDisplay length, width, and height fields on one line.
theme_uc_shipping_shipment_printDisplays the packing slip and shipping labels for printing.
theme_uc_stock_edit_formReturns HTML for uc_stock_edit_form().
theme_uc_store_footerWraps the footer in a div so it can be re-styled.
theme_uc_ups_confirm_shipmentDisplays final shipment information for review.
theme_uc_ups_label_imageDisplays the shipping label for printing.
theme_uc_ups_option_labelTheme function to format the UPS service name and rate amount line-item shown to the customer.
theme_uc_usps_option_labelTheme function to format the USPS service name and rate amount line-item shown to the customer.
theme_update_reportTheme project status report.
theme_update_versionTheme the version display of a project.
theme_upload_attachmentsDisplays file attachments in table
theme_upload_form_currentTheme the attachments list.
theme_upload_form_newTheme the attachment form. Note: required to output prefix/suffix.
theme_usernameFormat a username.
theme_user_admin_accountTheme user administration overview.
theme_user_admin_new_roleTheme the new-role form.
theme_user_admin_permTheme the administer permissions page.
theme_user_filtersTheme user administration filter selector.
theme_user_filter_formTheme user administration filter form.
theme_user_listMake a list of users.
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_signatureTheme output of user signature.
theme_xml_iconReturn code that emits an XML icon.


drupal/includes/, line 1085
The theme system, which controls the output of Drupal.