Default theme implementations
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 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 (Garland) to implement the 'table' hook, the phptemplate.engine would find garland_table().
The theme system is described and defined in theme.inc.
See also
theme()
@see hook_theme()
Functions
| Name | Location | Description |
|---|---|---|
| template_preprocess_menu_tree | includes/menu.inc | Preprocess the rendered tree for theme_menu_tree. |
| template_preprocess_username | includes/theme.inc | Preprocess variables for theme_username(). |
| template_process_username | includes/theme.inc | Process variables for theme_username(). |
| theme_admin_block | modules/system/system.admin.inc | This function formats an administrative block for display. |
| theme_admin_block_content | modules/system/system.admin.inc | This function formats the content of an administrative block. |
| theme_admin_page | modules/system/system.admin.inc | This function formats an administrative page for viewing. |
| theme_aggregator_page_opml | modules/aggregator/aggregator.pages.inc | Theme the OPML feed output. |
| theme_aggregator_page_rss | modules/aggregator/aggregator.pages.inc | Theme the RSS output. |
| theme_book_admin_table | modules/book/book.admin.inc | Theme function for the book administration page form. |
| theme_book_title_link | modules/book/book.module | Generate the HTML output for a link to a book title when used as a block title. |
| theme_breadcrumb | includes/theme.inc | Return a themed breadcrumb trail. |
| theme_button | includes/form.inc | Theme a button form element. |
| theme_checkbox | includes/form.inc | Theme a checkbox form element. |
| theme_checkboxes | includes/form.inc | Theme a set of checkbox form elements. |
| theme_comment_post_forbidden | modules/comment/comment.module | Theme a "you can't post comments" notice. |
| theme_confirm_form | modules/system/system.module | Theme confirmation forms. |
| theme_container | includes/form.inc | Adds a container for grouped items |
| theme_dashboard | modules/dashboard/dashboard.module | Theme the entire dashboard. |
| theme_dashboard_admin | modules/dashboard/dashboard.module | Theme the page containing the dashboard. |
| theme_dashboard_disabled_block | modules/dashboard/dashboard.module | Theme a disabled block, for display in dashboard customization mode. |
| theme_dashboard_disabled_blocks | modules/dashboard/dashboard.module | Theme a set of disabled blocks, for display in dashboard customization mode. |
| theme_dashboard_region | modules/dashboard/dashboard.module | Theme a generic dashboard region. |
| theme_date | includes/form.inc | Theme a date selection form element. |
| theme_dblog_filters | modules/dblog/dblog.module | Theme dblog administration filter selector. |
| theme_feed_icon | includes/theme.inc | Return code that emits an feed icon. |
| theme_fieldset | includes/form.inc | Theme a fieldset form element. |
| theme_file | includes/form.inc | Theme a file upload form element. |
| theme_filter_admin_order | modules/filter/filter.admin.inc | Theme filter order configuration form. |
| theme_filter_admin_overview | modules/filter/filter.admin.inc | Theme the text format administration overview form. |
| theme_filter_guidelines | modules/filter/filter.module | Format guidelines for a text format. |
| theme_filter_tips | modules/filter/filter.pages.inc | Render HTML for a set of filter tips. |
| theme_filter_tips_more_info | modules/filter/filter.module | Format a link to the more extensive filter tips. |
| theme_form | includes/form.inc | Theme a form. |
| theme_form_element | includes/form.inc | Theme a form element. |
| theme_form_required_marker | includes/form.inc | Theme the marker for required form elements. |
| theme_forum_form | modules/forum/forum.admin.inc | Theme forum forms. |
| theme_hidden | includes/form.inc | Theme a hidden form element. |
| theme_html_tag | includes/theme.inc | Generate the output for a generic HTML tag with attributes. |
| theme_html_tag | includes/theme.inc | Generate the output for a generic HTML tag with attributes. |
| theme_image | includes/theme.inc | Return a themed image. |
| theme_image_anchor | modules/image/image.admin.inc | Theme callback for displaying a grid of checkboxes. |
| theme_image_crop_summary | modules/image/image.admin.inc | Theme callback for image crop effect summary output. |
| theme_image_resize_summary | modules/image/image.admin.inc | Theme callback for image resize effect summary output. |
| theme_image_rotate_summary | modules/image/image.admin.inc | Theme callback for image rotate effect summary output. |
| theme_image_scale_summary | modules/image/image.admin.inc | Theme callback for image scale effect summary output. |
| theme_image_style_effects | modules/image/image.admin.inc | Theme callback for listing the effects within a specific image style. |
| theme_image_style_list | modules/image/image.admin.inc | Display the page containing the list of image styles. |
| theme_image_style_preview | modules/image/image.admin.inc | Theme callback for displaying a preview of an image style. |
| theme_indentation | includes/theme.inc | Create a standard indentation div. Used for drag and drop tables. |
| theme_item_list | includes/theme.inc | Return a themed list of items. |
| theme_links | includes/theme.inc | Return a themed set of links. |
| theme_locale_date_format_form | modules/locale/locale.module | Theme locale date format form. |
| theme_locale_languages_configure_form | includes/locale.inc | Theme the language configure form. |
| theme_locale_languages_overview_form | includes/locale.inc | Theme the language overview form. |
| theme_locale_translation_filters | modules/locale/locale.module | Theme locale translation filter selector. |
| theme_mark | includes/theme.inc | Return a themed marker, useful for marking new or updated content. |
| theme_menu_link | includes/menu.inc | Generate the HTML output for a menu link and submenu. |
| theme_menu_local_action | includes/menu.inc | Generate the HTML output for a single local action link. |
| theme_menu_local_task | includes/menu.inc | Generate the HTML output for a single local task link. |
| theme_menu_local_tasks | includes/menu.inc | Returns renderable local tasks. |
| theme_menu_tree | includes/menu.inc | Theme wrapper for the HTML output for a menu sub-tree. |
| theme_more_help_link | includes/theme.inc | Returns code that emits the 'more help'-link. |
| theme_more_link | includes/theme.inc | Returns code that emits the 'more' link used on blocks. |
| theme_node_add_list | modules/node/node.pages.inc | Display the list of available node types for node creation. |
| theme_node_filters | modules/node/node.admin.inc | Theme node administration filter selector. |
| theme_node_filter_form | modules/node/node.admin.inc | Theme node administration filter form. |
| theme_node_form | modules/node/node.pages.inc | Present a node submission form. |
| theme_node_list | modules/node/node.module | Format a listing of links to nodes. |
| theme_node_log_message | modules/node/node.module | Theme a log message. |
| theme_node_preview | modules/node/node.pages.inc | Display a node preview for display during node creation and editing. |
| theme_node_search_admin | modules/node/node.module | Theme the content ranking part of the search settings admin page. |
| theme_pager | includes/pager.inc | Format a query pager. |
| theme_pager_first | includes/pager.inc | Format a "first page" link. |
| theme_pager_last | includes/pager.inc | Format a "last page" link. |
| theme_pager_link | includes/pager.inc | Format a link to a specific query result page. |
| theme_pager_next | includes/pager.inc | Format a "next page" link. |
| theme_pager_previous | includes/pager.inc | Format a "previous page" link. |
| theme_password | includes/form.inc | Theme a password form element. |
| theme_placeholder | includes/theme.inc | Formats text for emphasized display in a placeholder inside a sentence. Used automatically by t(). |
| theme_poll_choices | modules/poll/poll.module | Theme the admin poll form for choices. |
| theme_profile_admin_overview | modules/profile/profile.admin.inc | Theme the profile field overview into a drag and drop enabled table. |
| theme_progress_bar | includes/theme.inc | Return a themed progress bar. |
| theme_radio | includes/form.inc | Theme a radio button form element. |
| theme_radios | includes/form.inc | Theme a set of radio button form elements. |
| theme_rdf_metadata | modules/rdf/rdf.module | Outputs a series of empty spans for exporting RDF metadata in RDFa. |
| theme_rdf_template_variable_wrapper | modules/rdf/rdf.module | Wraps a template variable in an HTML element with the desired attributes. |
| theme_scaffolding_example_overview_form | developer/examples/scaffolding_example/scaffolding_example.admin.inc | Theme the drag-and-drop overview form. |
| theme_scaffolding_example_record | developer/examples/scaffolding_example/scaffolding_example.pages.inc | Theme a single record. |
| theme_select | includes/form.inc | Theme select form element. |
| theme_shortcut_set_customize | modules/shortcut/shortcut.admin.inc | Theme function for the shortcut set customization form. |
| theme_shortcut_set_switch | modules/shortcut/shortcut.admin.inc | Theme function for the form that switches shortcut sets. |
| theme_status_messages | includes/theme.inc | Return a themed set of status and/or error messages. The messages are grouped by type. |
| theme_status_report | modules/system/system.admin.inc | Theme requirements status report. |
| theme_submenu | includes/theme.inc | Return a themed submenu, typically displayed under the tabs. |
| theme_submit | includes/form.inc | Theme a submit button form element. |
| theme_syslog_format | modules/syslog/syslog.module | Format a system log entry. |
| theme_system_admin_by_module | modules/system/system.admin.inc | Theme output of the dashboard page. |
| theme_system_compact_link | modules/system/system.module | Display the link to show or hide inline help descriptions. |
| theme_system_date_time_settings | modules/system/system.admin.inc | Theme function for date settings form. |
| theme_system_modules_fieldset | modules/system/system.admin.inc | Theme callback for the modules form. |
| theme_system_modules_incompatible | modules/system/system.admin.inc | Themes an incompatible message. |
| theme_system_modules_uninstall | modules/system/system.admin.inc | Themes a table of currently disabled modules. |
| theme_system_powered_by | modules/system/system.module | Format the Powered by Drupal text. |
| theme_system_run_cron_image | modules/system/system.module | Display image used to run cron automatically. |
| theme_system_settings_form | modules/system/system.module | Theme function for the system settings form. |
| theme_system_themes_form | modules/system/system.admin.inc | Theme function for the system themes form. |
| theme_table | includes/theme.inc | Return a themed table. |
| theme_tableselect | includes/form.inc | Format a table with radio buttons or checkboxes. |
| theme_tablesort_indicator | includes/theme.inc | Return a themed sort icon. |
| theme_table_select_header_cell | includes/theme.inc | Returns a header cell for tables that have a select all functionality. |
| theme_task_list | includes/theme.maintenance.inc | Return a themed list of maintenance tasks to perform. |
| theme_taxonomy_overview_terms | modules/taxonomy/taxonomy.admin.inc | Theme the terms overview as a sortable list of terms. |
| theme_taxonomy_overview_vocabularies | modules/taxonomy/taxonomy.admin.inc | Theme the vocabulary overview as a sortable list of vocabularies. |
| theme_textarea | includes/form.inc | Theme a textarea form element. |
| theme_textfield | includes/form.inc | Theme a textfield form element. |
| theme_text_format_wrapper | includes/form.inc | Theme a text format form element. |
| theme_trigger_display | modules/trigger/trigger.admin.inc | Displays actions assigned to this hook in a table. |
| theme_update_last_check | modules/update/update.module | Render the HTML to display the last time we checked for update data. |
| theme_update_manager_update_form | modules/update/update.manager.inc | Theme the first page in the update manager wizard to select projects. |
| theme_update_report | modules/update/update.report.inc | Theme project status report. |
| theme_update_version | modules/update/update.report.inc | Theme the version display of a project. |
| theme_upload_attachments | modules/upload/upload.module | Displays file attachments in table |
| theme_upload_form_current | modules/upload/upload.module | Theme the attachments list. |
| theme_upload_form_new | modules/upload/upload.module | Theme the attachment form. Note: required to output prefix/suffix. |
| theme_username | includes/theme.inc | Format a username. |
| theme_user_admin_new_role | modules/user/user.admin.inc | Theme the new-role form. |
| theme_user_admin_permissions | modules/user/user.admin.inc | Theme the administer permissions page. |
| theme_user_filters | modules/user/user.admin.inc | Theme user administration filter selector. |
| theme_user_filter_form | modules/user/user.admin.inc | Theme user administration filter form. |
| theme_user_list | modules/user/user.module | Make a list of users. |
| theme_user_profile | developer/theme.php | Theme a user page. |
| theme_user_signature | modules/user/user.module | Theme output of user signature. |
| theme_vertical_tabs | includes/form.inc | Makes the element's children fieldsets be vertical tabs. |
