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 theme.inc.

See also

theme()

@see hook_theme()

Functions

Namesort iconLocationDescription
theme_admin_blockdrupal-cvs/modules/system/system.admin.incThis function formats an administrative block for display.
theme_admin_block_contentdrupal-cvs/modules/system/system.admin.incThis function formats the content of an administrative block.
theme_admin_pagedrupal-cvs/modules/system/system.admin.incThis function formats an administrative page for viewing.
theme_aggregator_page_opmldrupal-cvs/modules/aggregator/aggregator.pages.incTheme the OPML feed output.
theme_aggregator_page_rssdrupal-cvs/modules/aggregator/aggregator.pages.incTheme the RSS output.
theme_blocksdrupal-cvs/includes/theme.incReturn a set of blocks available for the current user.
theme_book_admin_tabledrupal-cvs/modules/book/book.admin.incTheme function for the book administration page form. See alsobook_admin_table()
theme_book_title_linkdrupal-cvs/modules/book/book.moduleGenerate the HTML output for a link to a book title when used as a block title.
theme_boxdrupal-cvs/includes/theme.incReturn a themed box.
theme_breadcrumbdrupal-cvs/includes/theme.incReturn a themed breadcrumb trail.
theme_buttondrupal-cvs/includes/form.incTheme a form button.
theme_checkboxdrupal-cvs/includes/form.incFormat a checkbox.
theme_checkboxesdrupal-cvs/includes/form.incFormat a set of checkboxes.
theme_closuredrupal-cvs/includes/theme.incExecute hook_footer() which is run at the end of the page right before the close of the body tag.
theme_comment_admin_overviewdrupal-cvs/modules/comment/comment.admin.incTheme the comment admin form.
theme_comment_flat_collapseddrupal-cvs/modules/comment/comment.moduleTheme comment flat collapsed view.
theme_comment_flat_expandeddrupal-cvs/modules/comment/comment.moduleTheme comment flat expanded view.
theme_comment_post_forbiddendrupal-cvs/modules/comment/comment.moduleTheme a "you can't post comments" notice.
theme_comment_submitteddrupal-cvs/modules/comment/comment.moduleTheme a "Submitted by ..." notice.
theme_comment_thread_collapseddrupal-cvs/modules/comment/comment.moduleTheme comment thread collapsed view.
theme_comment_thread_expandeddrupal-cvs/modules/comment/comment.moduleTheme comment thread expanded view.
theme_comment_viewdrupal-cvs/modules/comment/comment.moduleTheme a single comment block.
theme_datedrupal-cvs/includes/form.incFormat a date selection element.
theme_dblog_filtersdrupal-cvs/modules/dblog/dblog.moduleTheme dblog administration filter selector.
theme_ec_address_overviewecommerce-cvs/ec_address/ec_address.module
theme_ec_address_pageecommerce-cvs/ec_address/ec_address.moduleAlmost all address pages may have this help text
theme_ec_anon_review_formecommerce-cvs/ec_anon/ec_anon.moduleInsert the email field in case the user is not logged
theme_ec_cart_display_blockecommerce-cvs/ec_cart/ec_cart.theme.incThemes the cart block. Called by ec_cart_display_block().
theme_ec_cart_display_block_itemecommerce-cvs/ec_cart/ec_cart.theme.incThemes the cart block item
theme_ec_cart_display_block_titleecommerce-cvs/ec_cart/ec_cart.theme.incThemes the cart block title
theme_ec_cart_view_formecommerce-cvs/ec_cart/ec_cart.theme.incReturns a themed shopping cart form.
theme_ec_checkout_admin_screen_formecommerce-cvs/ec_checkout/ec_checkout.theme.incThemes the admin screen
theme_ec_product_admin_ptypes_feature_listecommerce-cvs/ec_product/ec_product.theme.inc
theme_ec_product_autocompleteecommerce-cvs/ec_product/ec_product.theme.inc
theme_ec_product_edit_formecommerce-cvs/ec_product/ec_product.theme.inc
theme_ec_product_edit_form_productecommerce-cvs/ec_product/ec_product.theme.inc
theme_ec_product_priceecommerce-cvs/ec_product/ec_product.theme.incDisplay the product price
theme_ec_receipt_admin_rtypes_formecommerce-cvs/ec_receipt/ec_receipt.theme.inc
theme_ec_receipt_iconecommerce-cvs/ec_receipt/ec_receipt.theme.inc
theme_feed_icondrupal-cvs/includes/theme.incReturn code that emits an feed icon.
theme_fieldsetdrupal-cvs/includes/form.incFormat a group of form items.
theme_filedrupal-cvs/includes/form.incFormat a file upload field.
theme_filter_admin_orderdrupal-cvs/modules/filter/filter.admin.incTheme filter order configuration form.
theme_filter_admin_overviewdrupal-cvs/modules/filter/filter.admin.incTheme the admin overview form.
theme_filter_tipsdrupal-cvs/modules/filter/filter.pages.incFormat a set of filter tips.
theme_filter_tips_more_infodrupal-cvs/modules/filter/filter.moduleFormat a link to the more extensive filter tips.
theme_formdrupal-cvs/includes/form.incFormat a form.
theme_form_elementdrupal-cvs/includes/form.incReturn a themed form element.
theme_helpdrupal-cvs/includes/theme.incReturn a themed help message.
theme_hiddendrupal-cvs/includes/form.incFormat a hidden form field.
theme_imagedrupal-cvs/includes/theme.incReturn a themed image.
theme_image_buttondrupal-cvs/includes/form.incTheme a form image button.
theme_indentationdrupal-cvs/includes/theme.incCreate a standard indentation div. Used for drag and drop tables.
theme_invoice_form_productecommerce-cvs/ec_product/ec_product.theme.inc
theme_itemdrupal-cvs/includes/form.incFormat a form item.
theme_item_listdrupal-cvs/includes/theme.incReturn a themed list of items.
theme_linksdrupal-cvs/includes/theme.incReturn a themed set of links.
theme_locale_languages_overview_formdrupal-cvs/includes/locale.incTheme the language overview form.
theme_markdrupal-cvs/includes/theme.incReturn a themed marker, useful for marking new or updated content.
theme_menu_itemdrupal-cvs/includes/menu.incGenerate the HTML output for a menu item and submenu.
theme_menu_item_linkdrupal-cvs/includes/menu.incGenerate the HTML output for a single menu link.
theme_menu_local_taskdrupal-cvs/includes/menu.incGenerate the HTML output for a single local task link.
theme_menu_local_tasksdrupal-cvs/includes/menu.incReturns the rendered local tasks. The default implementation renders them as tabs.
theme_menu_overview_formdrupal-cvs/modules/menu/menu.admin.incTheme the menu overview form into a table.
theme_menu_treedrupal-cvs/includes/menu.incGenerate the HTML output for a menu tree
theme_meta_generator_headerdrupal-cvs/modules/system/system.moduleSend Drupal and the major version number in the HTTP headers.
theme_meta_generator_htmldrupal-cvs/modules/system/system.moduleSend Drupal and the major version number in the META GENERATOR HTML.
theme_more_help_linkdrupal-cvs/includes/theme.incReturns code that emits the 'more help'-link.
theme_more_linkdrupal-cvs/includes/theme.incReturns code that emits the 'more' link used on blocks.
theme_node_add_listdrupal-cvs/modules/node/node.pages.incDisplay the list of available node types for node creation.
theme_node_admin_nodesdrupal-cvs/modules/node/node.admin.incTheme node administration overview.
theme_node_filtersdrupal-cvs/modules/node/node.admin.incTheme node administration filter selector.
theme_node_filter_formdrupal-cvs/modules/node/node.admin.incTheme node administration filter form.
theme_node_formdrupal-cvs/modules/node/node.pages.incPresent a node submission form.
theme_node_listdrupal-cvs/modules/node/node.moduleFormat a listing of links to nodes.
theme_node_log_messagedrupal-cvs/modules/node/node.moduleTheme a log message.
theme_node_previewdrupal-cvs/modules/node/node.pages.incDisplay a node preview for display during node creation and editing.
theme_node_search_admindrupal-cvs/modules/node/node.moduleTheme the content ranking part of the search settings admin page.
theme_node_submitteddrupal-cvs/modules/node/node.moduleFormat the "Submitted by username on date/time" for each node
theme_pagerdrupal-cvs/includes/pager.incFormat a query pager.
theme_pager_firstdrupal-cvs/includes/pager.incFormat a "first page" link.
theme_pager_lastdrupal-cvs/includes/pager.incFormat a "last page" link.
theme_pager_linkdrupal-cvs/includes/pager.incFormat a link to a specific query result page.
theme_pager_nextdrupal-cvs/includes/pager.incFormat a "next page" link.
theme_pager_previousdrupal-cvs/includes/pager.incFormat a "previous page" link.
theme_passworddrupal-cvs/includes/form.incFormat a password field.
theme_password_confirmdrupal-cvs/includes/form.incFormat a password_confirm item.
theme_placeholderdrupal-cvs/includes/theme.incFormats text for emphasized display in a placeholder inside a sentence. Used automatically by t().
theme_poll_choicesdrupal-cvs/modules/poll/poll.moduleTheme the admin poll form for choices.
theme_priceecommerce-cvs/ec_product/ec_product.theme.inc
theme_profile_admin_overviewdrupal-cvs/modules/profile/profile.admin.incTheme the profile field overview into a drag and drop enabled table. See alsoprofile_admin_overview()
theme_progress_bardrupal-cvs/includes/theme.incReturn a themed progress bar.
theme_radiodrupal-cvs/includes/form.incFormat a radio button.
theme_radiosdrupal-cvs/includes/form.incFormat a set of radio buttons.
theme_scaffolding_example_overview_formdocs-cvs/examples/scaffolding_example/scaffolding_example.admin.incTheme the drag-and-drop overview form.
theme_scaffolding_example_recorddocs-cvs/examples/scaffolding_example/scaffolding_example.pages.incTheme a single record.
theme_selectdrupal-cvs/includes/form.incFormat a dropdown menu or scrolling selection box.
theme_status_messagesdrupal-cvs/includes/theme.incReturn a themed set of status and/or error messages. The messages are grouped by type.
theme_status_reportdrupal-cvs/modules/system/system.admin.incTheme requirements status report.
theme_submenudrupal-cvs/includes/theme.incReturn a themed submenu, typically displayed under the tabs.
theme_submitdrupal-cvs/includes/form.incTheme a form submit button.
theme_syslog_formatdrupal-cvs/modules/syslog/syslog.moduleFormat a system log entry.
theme_system_admin_by_moduledrupal-cvs/modules/system/system.admin.incTheme output of the dashboard page.
theme_system_compact_linkdrupal-cvs/modules/system/system.moduleDisplay the link to show or hide inline help descriptions.
theme_system_modules_fieldsetdrupal-cvs/modules/system/system.admin.incTheme callback for the modules form.
theme_system_modules_incompatibledrupal-cvs/modules/system/system.admin.incThemes an incompatible message.
theme_system_modules_uninstalldrupal-cvs/modules/system/system.admin.incThemes a table of currently disabled modules.
theme_system_powered_bydrupal-cvs/modules/system/system.moduleFormat the Powered by Drupal text.
theme_system_themes_formdrupal-cvs/modules/system/system.admin.incTheme function for the system themes form.
theme_system_theme_select_formdrupal-cvs/modules/system/system.admin.incTheme the theme select form.
theme_tabledrupal-cvs/includes/theme.incReturn a themed table.
theme_tablesort_indicatordrupal-cvs/includes/theme.incReturn a themed sort icon.
theme_table_select_header_celldrupal-cvs/includes/theme.incReturns a header cell for tables that have a select all functionality.
theme_task_listdrupal-cvs/includes/theme.maintenance.incReturn a themed list of maintenance tasks to perform.
theme_taxonomy_overview_termsdrupal-cvs/modules/taxonomy/taxonomy.admin.incTheme the terms overview as a sortable list of terms. See alsotaxonomy_overview_terms()
theme_taxonomy_overview_vocabulariesdrupal-cvs/modules/taxonomy/taxonomy.admin.incTheme the vocabulary overview as a sortable list of vocabularies. See alsotaxonomy_overview_vocabularies()
theme_taxonomy_term_pagedrupal-cvs/modules/taxonomy/taxonomy.pages.incRender a taxonomy term page HTML output.
theme_taxonomy_term_selectdrupal-cvs/modules/taxonomy/taxonomy.moduleFormat the selection field for choosing terms (by deafult the default selection field is used).
theme_textareadrupal-cvs/includes/form.incFormat a textarea.
theme_textfielddrupal-cvs/includes/form.incFormat a textfield.
theme_tokendrupal-cvs/includes/form.incFormat a form token.
theme_trigger_displaydrupal-cvs/modules/trigger/trigger.admin.incDisplay actions assigned to this hook-op combination in a table.
theme_update_reportdrupal-cvs/modules/update/update.report.incTheme project status report.
theme_update_versiondrupal-cvs/modules/update/update.report.incTheme the version display of a project.
theme_upload_attachmentsdrupal-cvs/modules/upload/upload.moduleDisplays file attachments in table
theme_upload_form_currentdrupal-cvs/modules/upload/upload.moduleTheme the attachments list.
theme_upload_form_newdrupal-cvs/modules/upload/upload.moduleTheme the attachment form. Note: required to output prefix/suffix.
theme_usernamedrupal-cvs/includes/theme.incFormat a username.
theme_user_admin_accountdrupal-cvs/modules/user/user.admin.incTheme user administration overview.
theme_user_admin_new_roledrupal-cvs/modules/user/user.admin.incTheme the new-role form.
theme_user_admin_permdrupal-cvs/modules/user/user.admin.incTheme the administer permissions page.
theme_user_filtersdrupal-cvs/modules/user/user.admin.incTheme user administration filter selector.
theme_user_filter_formdrupal-cvs/modules/user/user.admin.incTheme user administration filter form.
theme_user_listdrupal-cvs/modules/user/user.moduleMake a list of users.
theme_user_signaturedrupal-cvs/modules/user/user.moduleTheme output of user signature.
theme_xml_icondrupal-cvs/includes/theme.incReturn code that emits an XML icon.