Book Image

Drupal 7 Themes

By : Ric Shreves
Book Image

Drupal 7 Themes

By: Ric Shreves

Overview of this book

<p>Drupal is an award winning open source Content Management System (CMS). Based on PHP and MySQL, its power and flexibility combined with its exceptional design mean it is one of the most popular choices for creating a CMS website.</p> <p>Drupal employs a specialized templating system and supports themes, which allow you to change the look and feel of your system's front and back-end interfaces.</p> <p><em>Drupal 7 Themes</em> is an ideal introduction to theming with Drupal 7. If you want to create a striking new look for your Drupal 7 website, this book is for you. This book is a revised, updated and expanded edition of Drupal 6 Themes, rewritten specifically for Drupal 7.</p> <p>This book will show you techniques and tools to help you improve the look and feel of any Drupal 7-powered website. Starting from the basics of theme setup and configuration, you will learn about the Drupal theming architecture and the PHPTemplate engine, and then move on to modifying existing themes and building new themes from scratch. You will find out about tools to make your theme development easier.</p>
Table of Contents (17 chapters)
Drupal 7 Themes
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Identifying Templates, Stylesheets, and Themable Functions

A guide to Theming Elements


With the large assortment of templates, stylesheets, and themable functions available to you in the default Drupal distribution, finding exactly what you need can sometimes be a bit of a challenge. In an effort to simplify the process of isolating relevant theming elements, we present in the pages that follow a list of the elements organized relative to the functionality they affect.

Common Theme System functions

The theme.inc file controls the Drupal theme system. In addition to initializing and loading the theme system, the file contains a number of themable functions that relate specifically to various key elements in Drupal. The functions can be found in two files: includes/theme.inc and includes/theme.maintenance.inc.

Here is a table of the themable functions and a description of each one:

Function

Path

Description

theme_breadcrumb

includes/theme.inc

Handles the breadcrumb trail.

theme_disable

includes/theme.inc

Disables a list of themes.

theme_enable

includes/theme.inc

Enables a list of themes.

theme_feed_icon

includes/theme.inc

Enables a feed icon.

theme_get_registry

includes/theme.inc

Gets the theme registry.

theme_get_setting

includes/theme.inc

Retrieves a setting for a theme.

theme_get_suggestions

includes/theme.inc

Generates an array of suggestions from path arguments.

theme_html_tag

includes/theme.inc

Returns HTML for a tag with attributes.

theme_image

includes/theme.inc

Themes an image.

theme_indentation

includes/theme.inc

Provides a div for standardizing indentation.

theme_item_list

includes/theme.inc

Returns a themed list of items.

theme_link

includes/theme.inc

Returns HTML for a link.

theme_links

includes/theme.inc

Returns HTML for a list of links.

theme_mark

includes/theme.inc

Returns a themed marker for content (for example, new, updated).

theme_more_help_link

includes/theme.inc

Produces the more help link.

theme_more_link

includes/theme.inc

Produces the more link seen in blocks.

theme_progress_bar

includes/theme.inc

Displays the percentage complete progress bar.

theme_render_template

includes/theme.inc

Renders a system default template.

theme_status_messages

includes/theme.inc

Formats status and error messages.

theme_table

includes/theme.inc

Formats a table.

Function

Path

Description

theme_tablesort_indicator

includes/theme.inc

Produces the sort icon.

theme_username

includes/theme.inc

Formats the username.

Theming the Aggregator module

The Aggregator module provides a variety of functions related to the aggregation and display of syndicated content feeds (for example, RSS, RDF, and Atom).

Default templates

Theming the Aggregator module is made easier in Drupal 7 through the addition of several dedicated template files:

  • aggregator-feed-source.tpl.php

  • aggregator-item.tpl.php

  • aggregator-summary-item.tpl.php

  • aggregator-summary-items.tpl.php

  • aggregator-wrapper.tpl.php

The default templates are located at modules/aggregator/.

aggregator-feed-source.tpl.php

Provides a template for formatting the source of a feed. When a user is browsing the feed, they will see the output above the feed listings. The available variables include:

aggregator-item.tpl.php

Formats an individual feed item. The available variables include:

Variable

Description

$categories

Categories assigned to the feed.

$content

The content of the individual feed item.

$feed_title

The title of the feed item from the source of the feed.

$feed_url

The URL of the feed item from the source of the feed.

$source_date

The date of the item from the source of the feed.

$source_title

The title of the provider of the feed from the source of the feed.

$source_url

The URL to the source of the feed.

aggregator-summary-item.tpl.php

Themes a linked feed item for summaries. The available variables include:

Variable

Description

$feed_age

The age of the remote feed.

$feed_title

The title of the feed item from the source of the feed.

$feed_url

The URL of the feed item from the source of the feed.

$source_title

The title of the provider of the feed from the source of the feed.

$source_url

The URL to the source of the feed.

aggregator-summary-items.tpl.php

Themes a presentation of feeds as list items. The available variables include:

Variable

Description

$summary_list

The unordered list of feed items.

$source_url

The URL to the local source (or category).

$title

The title of the feed (or category).

aggregator-wrapper.tpl.php

Wraps aggregator content. The available variables include:

Variable

Description

$content

The entire aggregator contents.

$page

Pagination links.

Default stylesheets

Two stylesheets are dedicated to the formatting of the comments. Both are located at /modules/aggregator.

File

Description

aggregator.css

Affects the RSS/Newsfeed Aggregator Module and its contents.

aggregator-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are a number of themable functions that relate to the aggregator. The functions can be found in two files: modules/aggregator/aggregator.module and modules/aggregator/aggregator.pages.inc.

Function

Path

Description

theme_aggregator_block_item

modules/aggregator/aggregator.module

Formats an individual feed item displayed in a block.

theme_aggregator_catagorize_items

modules/aggregator/aggregator.pages.inc

Returns HTML for the aggregator page list form for assigning categories.

theme_aggregator_page_opml

modules/aggregator/aggregator.pages.inc

Allows you to theme the output of the OPML feed.

theme_aggregator_page_rss

modules/aggregator/aggregator.pages.inc

Allows you to theme the output of the RSS feed.

Theming the Block module

The Block module provides the mechanism for managing the blocks on the page.

Default templates

The system includes only two template files dedicated to blocks:

  • block.tpl.php

  • block-admin-display-form.tpl.php

The block.tpl.php template can be found at modules/system/.

The block-admin-display-form.tpl.php template can be found at modules/block/.

block.tpl.php

This is the key template for formatting blocks. The available variables include:

Variable

Description

$block->delta

The numeric ID associated with the module.

$block_html_id

A valid HTML ID.

$block->module

The module that generated the block.

$block->region

The region that contains the block.

$block->subject

The block title.

$block_id

ID unique to the block in the region.

$block_zebra

Provides an "odd/even" marker for the block. Alternates for each block used within a region.

$classes

String of classes that can be used to add contextual CSS styling.

$classes_array

An array of HTML class attributes. This is a helper variable and is flattened into a string within the variable $classes.

$content

The block content.

$id

Similar to $block_id but not dependent upon the region.

$is_admin

Returns True if user is an administrator.

$is_front

Returns True if user is viewing the front page.

$logged_in

Returns True if user is logged in and authenticated.

$title_prefix

An array of additional output intended to be displayed in front of the main title tag.

$title_suffix

An array of additional output intended to be displayed after the main title tag.

$zebra

Provides an "odd/even" marker for block but is not region dependent.

block-admin-display-form.tpl.php

The template controls the admin system's block configuration interface. The available variables include:

Variable

Description

$block_listing

An array of blocks keyed to region and delta.

$block_regions

The title of the region of the block.

$form_submit

The submit form button.

Default stylesheets

There is one style sheet dedicated to the block module. It is located at: /modules/block.

File

Description

block.css

Provides basic selectors for the styling of the block management admin interface

Theming the Book functionality

The Book module creates a node that allows for the creation of hierarchically organized groups of content items, united by a table of contents and common pagination. The book module provides the functions that impact book content and output.

Default templates

The default system includes four default template files dedicated to the book functionality:

  • book-all-books-block.tpl.php

  • book-export-html.tpl.php

  • book-navigation.tpl.php

  • book-node-export-html.tpl.php

The templates can be found at modules/book/.

book-all-books-block.tpl.php

The template renders book outlines within a block. The available variables include:

Variable

Description

$book_menus

An array of the book outline. Presented as an unordered list.

book-export-html.tpl.php

This template handles the printed version of the book outline. The available variables include:

Variable

Description

$base_url

The URL to the home page.

$contents

The nodes within the book outline.

$head

The header tags.

$language

The code indicating the language used.

$language_rtl

Returns True when the site uses right-to-left text orientation.

$title

The node's title.

book-navigation.tpl.php

Provides a template for formatting the navigation associated with a book node. The available variables include:

Variable

Description

$book_id

The ID of the current book being viewed.

$book_title

The title of the current book being viewed.

$book_url

The URL of the current book being viewed.

$current_depth

The current node's depth inside the outline.

$has_links

Returns True whenever the parent, previous, or next function has a value.

$next_title

The title of the next node.

$next_url

The URL of the next node.

$parent_title

The title of the parent node.

$parent_url

The URL of the parent node.

$prev_title

The title of the previous node.

$prev_url

The URL of the previous node.

$tree

The children of the current node, rendered as an unordered list.

book-node-export-html.tpl.php

Provides a template for formatting a printer-friendly version of the node. The available variables include:

Variable

Description

$children

All the child nodes associated.

Variable

Description

$content

The content of the node.

$depth

The current node's depth inside the outline.

$title

The title of the node.

Default stylesheets

Two stylesheets are dedicated to the formatting of books. Both are located at /modules/book.

File

Description

book.css

Controls the formatting of Book node content.

book-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are only two themable functions that relate to books. The functions can be found in two locations: modules/book/book.module and modules/book/book.admin.inc.

Function

Path

Description

theme_book_admin_table

modules/book/book.admin.inc

Themes the book administration page.

theme_book_title_link

modules/book/book.module

Provides the HTML output for the link to the book title, when it is used as a block title.

Theming the Color module

The Color module provides the color change functionality seen in the theme configuration manager of some themes.

Default templates

There are no default templates provided for the Color module.

Default stylesheets

Two stylesheets are dedicated to the Color module. Both are located at /modules/color.

File

Description

color.css

Controls the Color module used with some themes.

color-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There is only one themable function associated with the Color module:

Function

Path

Description

theme_color_scheme_form

modules/color/color.module

Controls formatting of the Color Module form.

Theming the Comment functionality

The comment functionality allows users to add comments to published content.

Default templates

Theming the comments is Drupal 7 is handled by two dedicated template files:

  • comment-wrapper.tpl.php

  • comment.tpl.php

The default templates are located at modules/comment/.

comment-wrapper.tpl.php

This template is used to wrap all the comments. It is a container that controls the overall formatting of the comment area. The available variables include:

Variable

Description

$classes

String of classes that can be used to provide contextual CSS styling.

$classes-array

Array of HTML class attributes, flattened into a string within the variable $classes.

$content

Handles all the comments for a particular page.

Variable

Description

$node

The node object the comments are attached to.

$title_prefix

An array of additional output that is displayed in front of the main title tag.

$title_suffix

An array of additional output that is displayed after the main title tag.

comment.tpl.php

This is the primary template for controlling the appearance of a comment. The available variables include:

Variable

Description

$author

The name of the author of the comment.

$changed

Date and time comment was last changed.

$classes

String of classes that can be used to provide contextual CSS styling.

$comment

The full comment object.

$content

The main body of the comment.

$created

Date and time comment was created.

$date

The date and time the comment was posted.

$links

The links associated with the functionality.

$new

A marker that indicates a new comment.

$node

The node object the comments are attached to.

$permalink

Comment's permalink.

$picture

The author's picture.

$signature

The author's signature.

$status

The status of the comment (that is, published, unpublished, and so on).

$submitted

Submitted by text with date and time.

$title

The title of the comment, linked to the comment body.

$title_prefix

An array of additional output that is displayed in front of the main title tag.

$title_suffix

An array of additional output that is displayed after the main title tag.

Default stylesheets

Two stylesheets are dedicated to the formatting of the comments. Both are located at /modules/comment.

File

Description

comment.css

This is a very limited stylesheet which essentially only provides the indent style for comments.

comment-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are only two themable functions that relate to the comment functionality. The functions can be found at: modules/comment/comment.module.

Function

Path

Description

theme_comment_block

modules/comment/comment.module

Formats the list of recent comments displayed within a block.

theme_comment_post_forbidden

modules/comment/comment.module

Controls the you can't post comments function.

Theming the Dashboard module

The Dashboard module handles the administration interface dashboard. As there is no frontend output from this module, the theming options are limited.

Default templates

There are no default templates provided for the dashboard functionality.

Default stylesheets

There is one stylesheet dedicated to the formatting of the dashboard. It is located at /modules/dashboard.

File

Description

dashboard.css

This stylesheet provides the styling of the dashboard.

Themable functions

There are several themable functions associated with the Dashboard module. The functions can be found at: modules/filter/dashboard.module.

Function

Path

Description

theme_dashboard

modules/dashboard/dashboard.module

Returns the HTML for the entire dashboard

theme_dashboard_admin

modules/dashboard/dashboard.module

The HTML for the non-customizable portion of the dashboard.

theme_dashboard_region

modules/dashboard/dashboard.module

Styling for the generic dashboard region.

theme_dashboard_disabled_blocks

modules/dashboard/dashboard.module

Styling for a set of disabled blocks.

theme_dashboard_disabled_block

modules/dashboard/dashboard.module

Styling for a disabled block.

Theming the DBLog module

The DBLog records system events and allows administrators to monitor their system. There is no frontend functionality associated with this module, hence the theming options are limited.

Default templates

There are no default templates provided for the DBLog module.

Default stylesheets

Two stylesheets are dedicated to the formatting of the dblog. Both are located at /modules/dblog.

File

Description

dblog.css

Provides the styles for the dblog admin interface.

dblog-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There is only one themable function associated with the DBLog module.

Function

Path

Description

theme_dblog_message

modules/dblog/dblog.admin.inc

Returns the HTML for a log message.

Theming the Field module

The Field module powers the custom field creation.

Default templates

There is one dedicated template file:

  • * field.tpl.php

The default template is located at modules/field/theme.

field.tpl.php

This template is not actually used in the system, but is simply provided as a starting point for customization. If needed, copy and place in the active theme directory. The available variables include:

Variable

Description

$classes

String of classes that can be used to provide contextual CSS styling.

$classes-array

Array of HTML class attributes, flattened into a string within the variable $classes.

$element['#field_language']

The field language.

$element['#field_name']

The field name.

$element['#field_translatable']

Whether the field is translatable.

$element['#field_type']

The field type.

$element['#label_display']

The position of the label display.

Variable

Description

$element['#view_mode']

View mode full or teaser.

$field_name_css

CSS compatible field name.

$field_type_css

CSS compatible field type.

$items

An array of field values.

$label

The item label.

$label_hidden

Whether the label is set to hidden.

Default stylesheets

Two stylesheets are dedicated to the formatting of the field. Both are located at /modules/field/theme.

File

Description

field.css

A limited set of styles for the fields and the field form.

field-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are several themable functions associated with the Field module. The functions can be found in three files: modules/field/field.module, modules/field/field.form.inc, and modules/field/modules/options/options.module.

Function

Path

Description

theme_field

modules/field/field.module

The HTML for a field.

theme_field_multiple_value_form

modules/field/field.form.inc

HTML for an individual form element.

theme_options_none

modules/field/modules/options/options.module

The HTML for the label for values not required.

Theming the Field UI module

The Field UI module gives an interface for managing custom fields. As there is no frontend output from this module, the theming options are limited.

Default templates

There are no dedicated templates file.

Default stylesheets

Two stylesheets are dedicated to the formatting of the field. Both are located at /modules/field_ui.

File

Description

field_ui.css

Basic styling for the fields user interface.

field_ui-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There is one themable function associated with the Field UI module. The function can be found at: modules/field_ui/field_ui.admin.inc.

Function

Path

Description

theme_field_ui_table

modules/field_ui/field_ui.admin.inc

The HTML for Field UI overview tables.

Theming the File module

The File module provides the file field.

Default templates

There are no dedicated template files.

Default stylesheets

There is one stylesheet for the File module, located at /modules/file.

File

Description

file.css

Basic styling for the file element.

Themable functions

There are several themable functions associated with the File module. The functions can be found at: modules/file/file.field.inc.

Function

Path

Description

theme_file_formatter_table

modules/file/file.field.inc

Styling for the file attachments table.

theme_file_icon

modules/file/file.field.inc

HTML for the icon associated with the file type.

theme_file_link

modules/file/file.field.inc

HTML for a link to the file.

theme_file_managed_file

modules/file/file.field.inc

Styling for a managed file element.

theme_file_upload_help

modules/file/file.field.inc

Styling for the help text for the file uploader.

theme_file_widget

modules/file/file.field.inc

HTML for an individual file upload widget.

theme_file_widget_multiple

modules/file/file.field.inc

HTML for a group of file upload widgets.

Theming the Filter module

The Filter module allows administrators to specify the text input formats for the site and filter out things that are potentially malicious or harmful. As there is no frontend output from this module, the theming options are limited.

Default templates

There are no default templates provided for the filter functionality.

Default stylesheets

There is one stylesheet for the Filter module, located at /modules/filter.

File

Description

filter.css

Basic styling for the filter functionality.

Themable functions

There are several themable functions associated with the Filter module. The functions can be found in three files: modules/filter/filter.module, modules/filter/filter.admin.inc, and modules/filter/filter.pages.inc.

Function

Path

Description

theme_filter_admin_format_filter_order

modules/filter/filter.admin.inc

HTML for a text format's filter order form.

theme_filter_admin_overview

modules/filter/filter.admin.inc

Themes the admin overview form for filters.

theme_filter_guidelines

modules/filter/filter.admin.inc

HTML for guidelines for a text format.

theme_filter_tips

modules/filter/filter.pages.inc

Formats the filter tips.

theme_filter_tips_more_info

modules/filter/filter.module

Formats the filter tips more info link.

theme_text_format_wrapper

modules/filter/filter.module

HTML for a text format enabled form element.

Theming the Form functionality

Handles the various forms and their elements.

Default templates

There are no default templates provided for the form functionality.

Default stylesheets

There are no stylesheets dedicated to the form functionality.

Themable functions

There exists a large number of themable functions associated with forms. The functions can be found at: includes/form.inc.

Function

Path

Description

theme_button

includes/form.inc

Formats a button.

theme_checkbox

includes/form.inc

Formats an individual checkbox.

theme_checkboxes

includes/form.inc

Handles a set of checkboxes.

Function

Path

Description

theme_container

includes/form.inc

The HTML to wrap the child elements in a container.

theme_date

includes/form.inc

Formats the date selection element.

theme_fieldset

includes/form.inc

Formats a group of form items.

theme_file

includes/form.inc

Formats a file upload field.

theme_form

includes/form.inc

Provides an anonymous<div> for forms to help satisfy XHTML compliance requirements.

theme_form_element

includes/form.inc

Returns a themed form element, including the this field is required message.

theme_form_element_label

includes/form.inc

HTML for a form element label.

theme_form_required_marker

includes/form.inc

The HTML for the "required" marker.

theme_hidden

includes/form.inc

Formats a hidden form field.

theme_image_button

includes/form.inc

Handles formatting of a form image button.

theme_menu_link

includes/form.inc

Styling for a menu link and submenu.

theme_menu_local_action

includes/form.inc

Formats a single local action link.

theme_menu_local_task

includes/form.inc

Formats a single local task link.

theme_menu_local_tasks

includes/form.inc

Formats the primary and secondary local tasks.

theme_menu_tree

includes/form.inc

The HTML for a wrapper for a menu sub-tree.

theme_password

includes/form.inc

Formats a password field.

theme_radio

includes/form.inc

Formats a radio button.

theme_radios

includes/form.inc

Formats a set of radio buttons.

theme_select

includes/form.inc

Formats a drop-down menu or scrolling selection box.

theme_submit

includes/form.inc

Formatting of the submit button on a form.

Function

Path

Description

theme_tableselect

includes/form.inc

HTML for a table with select controls (that is, radio buttons or checkboxes).

theme_textarea

includes/form.inc

Formats a text area within a form.

theme_textfield

includes/form.inc

Formats a text field within a form.

theme_vertical_tabs

includes/form.inc

Formats an element's children as vertical tabs

Note

Forms are discussed in greater length in Chapter 8,

Theming the Forum module

The Forum module handles the threaded discussion forums in Drupal. As this is a fairly complex module with a significant role on the frontend of the system, it is not surprising that there are a number of options available for theming this functionality.

Default templates

The default system includes five default template files dedicated to the forum functionality:

  • forum-icon.tpl.php

  • forum-list.tpl.php

  • forum-submitted.tpl.php

  • forum-topic-list.tpl.php

  • forums.tpl.php

The templates can be found at modules/forum/.

forum-icon.tpl.php

Displays the icon associated with a post (for example, new, sticky, closed, and so on). The available variables include:

Variable

Description

$first_new

Indicator showing that the item is the first topic with new posts.

$icon

The icon to be displayed.

$new_posts

Indicates whether the topic includes any new posts.

forum-list.tpl.php

Template to control the display of the list of forums and containers. The available variables include:

Variable

Description

$forum_id

The ID of the current forum.

$forum->depth

Depth of forum within content hierarchy.

$forum->description

Forum's description

$forum->is_container

TRUE if the forum containers other forums.

$forum->last_reply

Last time a forum was posted or commented on.

$forum->link

URL of the forum.

$forum->name

Forum's name.

$forum->new_topics

TRUE if the forum contains unread posts.

$forum->new_text

Tells how many new posts.

$forum->new_url

URL to unread posts.

$forum->num_posts

Total number of posts in forum.

$forum->old_topics

Count of posts already read.

$forum->zebra

Even or odd string used for row classes.

$forums

An array of forums and containers.

forum-submitted.tpl.php

This template controls the submitted by… information. The available variables include:

Variable

Description

$author

The name of the author of the post.

$time

When the post was made.

$topic

The raw post data.

forum-topic-list.tpl.php

This template displays a list of the forum topics. The available variables include:

Variable

Description

$header

The table header.

$pager

The pagination elements.

$topic_id

Numerical ID for current topic.

$topics

An array of the topics.

$topic->comment_count

The number of replies to the topic.

$topic->created

When the topic was posted.

$topic->icon

The icon.

$topic->last_reply

When the topic was last replied to.

$topic->message

The explanation and link for when a topic has been moved.

$topic->moved

Flag to indicate a moved topic.

$topic->new_replies

Flag to indicate unread comments.

$topic->new_text

Text containing the count.

$topic->new_url

URL to any unread replies.

$topic->timestamp

Raw timestamp for when topic was posted.

$topic->title

The title of the topic.

$topic->zebra

Even or odd string used for row classes.

forums.tpl.php

The template for the forum as a whole. The available variables include:

Variable

Description

$forums

The forums to be displayed.

$forums_defined

A flag to indicate whether the forum has been defined.

$topics

The topics to be displayed.

Default stylesheets

Two stylesheets are dedicated to the formatting of the forums. Both are located at /modules/forum.

File

Description

forum.css

Affects the contents of the forum module.

forum-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There is one additional themable function associated with the forum module:

Function

Path

Description

theme_forum_form

modules/forum/forum.admin.inc

Formats the Forum form.

Theming the Help module

The Help module powers the context-sensitive help information, most often seen in the admin interface.

Default templates

There are not default templates dedicated to the help functionality.

Default stylesheets

There are two stylesheets dedicated to the Help module. Both are located at /modules/help.

File

Description

help.css

Contains two selectors to style the help function.

help-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are no additional themable functions associated with the help messages.

Theming the Image functionality

The Image module assists with the image field and image management.

Default templates

There are no default templates dedicated to the image functionality.

Default stylesheets

There are three stylesheets dedicated to the image module. They are located at /modules/image.

File

Description

image.css

Provides selectors for preview and the widget.

image-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

image.admin.css

Selectors for the admin view.

Themable functions

There are multiple themable functions related to the image functionality. They can be found in three separate files:

Function

Path

Description

theme_image_anchor

modules/image/admin.inc

Formats the 3x3 grid of checkboxes for image anchors.

theme_image_crop_summary

modules/image/admin.inc

HTML for summary of image crop effect.

theme_image_formatter

modules/image/field.inc

HTML for the image field formatter.

theme_image_resize_summary

modules/image/admin.inc

HTML for summary of image resize effect.

theme_image_rotate_summary

modules/image/admin.inc

HTML for summary of image rotate effect.

theme_image_scale_summary

modules/image/admin.inc

HTML for summary of image scale effect.

theme_image_style

modules/image/image.module

Formats an image using a specific style.

theme_image_style_effects

modules/image/admin.inc

HTML for the listing of the effects in a specific image style.

Function

Path

Description

theme_image_style_list

modules/image/admin.inc

Formats the page containing the list of image styles.

theme_image_style_preview

modules/image/admin.inc

HTML for the preview of an image style.

theme_image_widget

modules/image/field.inc

Formats the image field widget.

Theming the Locale functionality

The Locale module enables administrators to manage a site's interface languages.

Default templates

There are no default templates dedicated to the locale functionality.

Default stylesheets

There is only one stylesheet dedicated to the Locale module. It is located at /modules/locale.

File

Description

locale.css

Provides a selector for the Locale module.

Themable functions

There are three themable functions related to the locale functionality:

Function

Path

Description

theme_locale_date_format_form

includes/locale.admin.inc

Formats the local date format form.

theme_locale_languages_configure_form

includes/locale.admin.inc

HTML for a language configuration page.

theme_locale_languages_overview_form

includes/locale.admin.inc

Themes the locale admin manager form.

Theming the Menu functionality

The Menu module allows administrators to customize the site navigation menu.

Default templates

There are no default templates dedicated to the Menu module.

Default stylesheets

There is only one stylesheet dedicated to the Menu module. It is located at /modules/menu.

File

Description

menu.css

Provides three selectors for the menu module.

Themable functions

There are only two themable functions that relate to the Menu module.

Function

Path

Description

theme_menu_admin_overview

module/menu/menu.admin.inc

HTML for the menu title and description for the menu overview page.

theme_menu_overview_form

module/menu/menu.admin.inc

Themes the menu overview form.

Theming the Node functionality

The Node module allows content to be submitted to the site, in various forms.

Default templates

The Node module provides a single dedicated template file, but it is key. This one template provides many formatting options and handles all node content:

  • modules/node/node.tpl.php

node.tpl.php

This template controls node display. This is a powerful and important template and accordingly there are a number of variables associated with it:

Variable

Description

$classes

String of classes that can be used to provide contextual CSS styling.

$classes-array

Array of HTML class attributes; flattened into a string within the variable $classes.

Variable

Description

$comment

The comment settings for the node.

$comment_count

The number of comments tied to the node.

$content

The node body and/or teaser.

$created

The time the node was published.

$date

The creation date of the node.

$display_submitted

Whether submission information should be displayed.

$id

The position of the node.

$is_admin

Returns True when the current user is an administrator.

$is_front

Returns True when the current page is the front page.

$logged_in

Returns True when the current user is logged in and authenticated.

$name

The username of the node's author.

$node

The full node object.

$node_url

The URL of the current node.

$page

Flag indicating full page state.

$promote

Flag indicating from page promotion state.

$readmore

Flag indicating length of node exceeds teaser limit.

$status

Flag indicating published state.

$sticky

Flag indicating sticky state.

$submitted

The submitted by… information.

$teaser

Flag indicating the teaser state.

$title

The node's title.

$title_prefix

An array of additional output that is displayed before the main title tag.

$title_suffix

An array of additional output that is displayed after the main title tag.

$type

The node type (for example, story, blog, and so on).

$uid

The user ID of the node's author.

$user_picture

The picture of the node's author.

$view_mode

The view of the node (that is, teaser, full).

$zebra

Even or odd string used for row classes.

Default stylesheets

Two stylesheets are dedicated to the node module. Both are located at: /modules/node.

File

Description

node.css

Provides selectors for nodes.

node-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are a number of themable functions that relate to the node functionality. The functions can be found in three files: modules/node/node.module, modules/node/node.admin.inc, and modules/node/node.pages.inc.

Function

Path

Description

theme_node_add_list

modules/node/node.pages.inc

Displays the list of available node types.

theme_node_admin_overview

modules/node/content_types.inc

Formats the node administration overview.

theme_node_preview

modules/node/node.pages.inc

The node preview used during content creation and editing.

theme_node_recent_block

modules/node/node.module

Formats a list of recent content.

theme_node_recent_content

modules/node/node.module

Formats the recent node displayed in the recent content block.

theme_node_search_admin

modules/node/node.module

Renders the admin node search form.

Theming the OpenID module

The OpenID module enables authentication with the OpenID protocol.

Default templates

There are no default templates provided for the OpenID module.

Default stylesheets

There is one stylesheet dedicated to the OpenID module, located at: /modules/openid.

File

Description

openid.css

Provides selectors specific to authentication with the OpenID system.

openid-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are no additional themable functions associated with the OpenID module.

Theming the Overlay module

The Overlay module provides the admin system overlay.

Default templates

There are no default templates provided for the Overlay module.

Default stylesheets

There are two stylesheets dedicated to the Overlay module, located at: /modules/overlay.

File

Description

overlay-child.css

Selectors for the tabs, titles, and controls on the overlay elements.

overlay-patent.css

Basic overlay selectors.

Themable functions

There is only one themable function associated with the Overlay module.

Function

Path

Description

theme_overlay_disable_message

modules/overlay/overlay.module

Formats the message containing instructions for how to disable the overlay.

Theming the Poll module

Controls the formatting and display of the Poll module, including the voting forms and the results.

Default templates

There are five dedicated templates for the poll functionality, covering block and page output:

  • poll-bar--block.tpl.php

  • poll-bar.tpl.php

  • poll-results--block.tpl.php

  • poll-results.tpl.php

  • poll-vote.tpl.php

The default templates are located at modules/poll/.

poll-bar--block.tpl.php

Provides a template for formatting the results bar of a single poll answer choice, applicable when poll is in block position. The available variables include:

Variable

Description

$percentage

The percentage of total votes received by this answer choice.

$title

The title of the poll.

$total_votes

The number of votes cast for this answer choice.

$vote

The current user's vote on the poll.

$voted

Returns True if the user had voted on this poll.

$votes

The total number of votes cast in the poll.

poll-bar.tpl.php

Displays the bar for a single choice in the poll. The available variables are the same as those for the template poll-bar-block.tpl.php, above.

poll-results.tpl.php

Provides a template for the display of poll results. The available variables include:

Variable

Description

$cancel_form

The form for a user to cancel their vote.

$links

Links in the poll.

$nid

The NID of the poll.

$raw_links

Raw array of links in the poll.

$results

The results of the poll.

$title

The title of the poll.

$vote

The current user's vote on the poll.

$votes

The total number of votes cast in the poll.

poll-results--block.tpl.php

Provides a template for the display of poll results, applicable in block position. The available variables are the same as those for poll-results.tpl.php.

poll-vote.tpl.php

Provides a template for the voting form for a poll. The available variables include:

Variable

Description

$block

Returns True if this is being displayed in a block.

$choice

The radio buttons for voting on the choices in the poll.

$rest

A catch-all to pick up anything else that may have been added via hooks.

$title

The title of the poll.

$vote

The vote button.

Default stylesheets

Two stylesheets are dedicated to the formatting of the Poll module. Both are located at /modules/poll.

File

Description

poll.css

Styling for Polls.

poll-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are no additional themable functions associated with the Poll module.

Theming the Profile module

The Profile module deals with the user profile pages.

Default templates

Drupal 7 provides three dedicated template files to assist with formatting the profile functionality:

  • profile-block.tpl.php

  • profile-listing.tpl.php

  • profile-wrapper.tpl.php

The default templates are located at modules/profile/.

profile-block.tpl.php

Handles the display of a user's profile within a block. The available variables include:

Variable

Description

$field_title

The title of the profile field.

$field_type

The type of the profile field.

$field_value

The value of the profile field.

$profile

Array of all profile fields that have data.

$user_picture

The image associated with the user.

profile-listing.tpl.php

Provides a template for the user information on the member listing page. The available variables include:

Variable

Description

$account

User's account object.

$field_title

The title of the profile field.

$field_type

The type of the profile field.

$field_value

The value of the profile field.

$name

The name of the user.

Variable

Description

$user_picture

The image associated with the user.

$profile

Array of all profile fields that have data.

profile-wrapper.tpl.php

The template that is used for displaying a list of users. The available variables include:

Variable

Description

$content

The user account profiles.

$current_field

The field being browsed.

Default stylesheets

There is only one stylesheet dedicated to the profile functionality.

File

Description

profile.css

There are only three selectors here for the profile fields.

Themable functions

There is only one themable function that relates to the profile functionality.

Function

Path

Description

theme_profile_admin_overview

modules/profile/profile.admin.inc

Themes the profile field overview.

Theming the Search module

The Search module powers the various search options for Drupal.

Default templates

There are three default templates for theming the search forms:

  • search-block-form.tpl.php

  • search-result.tpl.php

  • search-results.tpl.php

The default templates are located at modules/search/.

search-block-form.tpl.php

Provides a template for displaying a search form within a block. The available variables include:

Variable

Description

$search

The complete search form.

$search_form

An array of search form elements.

$search['hidden']

Handles hidden form elements.

$search['search_block_form']

Formats the text input area.

$search['submit']

Handles the form submit button.

search-result.tpl.php

This template renders a single search result. The available variables include:

Variable

Description

$classes-array

Array of HTML class attributes, flattened into a string within the variable $classes.

$content_attributes_array

An array of HTML attributes for the content.

$info

String of all the meta information.

$info_split

Contains the same data as $info, but it is split into an array.

$info_split['comment']

Number of comments.

$info_split['date']

Last update of the node.

$info_split['type']

The node type.

$info_split['upload']

Number of attachments.

$info_split['user']

Author of the node.

$module

The machine-readable name of the module being searched.

$title

The title of the result.

$title_attributes_array

Array of HTML attributes for the title.

$title_prefix

An array of additional output that is displayed in front of the main title tag.

$title_suffix

An array of additional output that is displayed after the main title tag.

Variable

Description

$type

The type of search.

$url

The URL of the result.

search-results.tpl.php

Provides a template for rendering the set of search results. The available variables include:

Variable

Description

$search_results

All results.

$module

The machine-readable name of the module.

Default stylesheets

Two stylesheets are dedicated to the formatting of the search functionality. Both are located at /modules/search.

File

Description

search.css

Styling for the Search module.

search-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are no additional themable functions associated with the search function.

Theming the Shortcut module

The Shortcut module handles the shortcuts functionality associated with the toolbar area of the admin system.

Default templates

There are no default templates provided for the Shortcut module.

Default stylesheets

File

Description

shortcut.admin.css

Two basic selectors affecting shortcut display.

shortcut.css

The primary stylesheet for formatting the shortcuts.

Themable functions

There is only one themable function associated with the Shortcut module.

Function

Path

Description

theme_shortcut_set_customiza

modules/shortcut/shortcut.admin.inc

Provides the formatting for the shortcut set customization form.

Theming the System module

The System module plays an important role in Drupal. The module provides important functionality for generating pages as well as handling the various configuration controls that help administrators modify the workings of the site.

Default templates

The System module contains some of the most important templates in Drupal. The page and box templates are two key files for theming your site.

  • html.tpl.php

  • maintenance-page.tpl.php

  • page.tpl.php

  • region.tpl.php

The default templates are located at: modules/system/.

html.tpl.php

Provides a template for providing essential information included in all themes, for example, the namespace.

Variable

Description

$classes

Classes used to provide contextual CSS styling.

$css

An array of the CSS files for the current page.

Variable

Description

$grddl_profile

A GRDDL profile to be used for extracting RDF data.

$head

The markup for the<head> section.

$head_title

The page title, for use in the TITLE tag.

$head_title_array

Contains the parts used to generate the $head_title variable.

$language

The language the site is displayed in.

$page

The rendered page content.

$page_bottom

Closing markup from any modules that have altered the page.

$page_top

Markup from modules that have altered the page.

$rdf_namespaces

The RDF namespace prefixes.

$scripts

Loads the JavaScript files.

$styles

To import all the CSS files for the page.

maintenance-page.tpl.php

Provides a template for formatting the "site under maintenance" page. The available variables are the same as those applicable to the html.tpl.php and the page.tpl.php files.

page.tpl.php

Provides an important template for controlling the output on a Drupal page. The available variables include:

Variable

Description

$action_links

An array of actions local to the page.

$base_path

The base path of the Drupal installation.

$breadcrumb

The breadcrumb trail for the current page.

$directory

The directory where the theme is located.

$feed_icons

A string of the feed icons relevant to the page.

$front_page

The URL of the front page.

$is_admin

Returns True is user is an administrator.

$is_front

Returns True if current page is the front page.

$logged_in

Returns True if user is logged in and authenticated.

$logo

The path to the logo image.

$main_menu

An array of the main menu links.

$messages

The status and error messages.

Variable

Description

$node

The node object.

$page['content']

A region, in this case, the main content area.

$page['footer']

A region, in this case, the footer region.

$page['header']

A region, in this case, the header region.

$page['help']

A region, in this case, the region that displays the help messages.

$page['highlighted']

A region, in this case, the highlighted content region.

$page['sidebar_first']

A region, in this case, the first sidebar.

$page['sidebar_second']

A region, in this case, the second sidebar.

$secondary_menu

An array containing the secondary menu links.

$site_name

The name of the site, as defined in the admin system.

$site_slogan

The site slogan, as defined in the admin system.

$tabs

The tabs linking to sub-pages (for example, edit).

$title

The page title.

$title_prefix

An array of additional output that is displayed in front of the main title tag.

$title_suffix

An array of additional output that is displayed after the main title tag.

region.tpl.php

Provides a template for creating a box around items. The available variables include:

Variable

Description

$classes

Classes used to provide contextual CSS styling.

$classes-array

Array of HTML class attributes, flattened into a string within the variable $classes.

$content

The content for the region (typically blocks).

$is_admin

Returns True when the current user is the admin user.

$is_front

Returns True when the current page is the front page.

$logged_in

Returns True when the current user is logged in and authenticated.

$region

The name of the region variable.

Default stylesheets

There are a large number of stylesheets associated with the System module, however, the primary styling of the key templates discussed above is typically managed from within the styles.css file located in the theme directory. The following stylesheets are located at: modules/system.

File

Description

system.admin.css

Contains the styles for the administration pages.

system.admin-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

system.base.css

The Drupal system's theme agnostic styles.

system.base-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

system.maintenance.css

The styles for the maintenance page.

system-menus.css

Covers a wide variety of common styles, and also includes menus, tabs, and progress bars.

system-menus-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

system.messages.css

Styling for the system messages.

system.theme.css

Basic styling for common markup.

system.theme-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are a number of themable functions that relate to the System module. The functions can be found in two files: modules/system/system.module and modules/system/system.admin.inc.

Function

Path

Description

theme_admin_block

modules/system/system.admin.inc

Handles the admin system block display.

theme_admin_block_content

modules/system/system.admin.inc

Formats the contents of the admin block.

theme_admin_page

modules/system/system.admin.inc

Formats the administration page.

theme_confirm_form

modules/system/system.module

Formats the confirmation form.

Function

Path

Description

theme_exposed_filters

modules/system/system.module

HTML for the exposed filters form.

theme_status_report

modules/system/system.admin.inc

Themes the admin system's status report page.

theme_system_admin_index

modules/system/system.admin.inc

Formats the output of the admin dashboard page.

theme_system_compact

modules/system/system.module

Formats the link to show or hide the help descriptions.

theme_system_date_time_settings

modules/system/system.admin.inc

Formats the date setting form.

theme_system_modules_fieldset

modules/system/system.admin.inc

HTML for the modules form.

theme_system_modules_incompatible

modules/system/system.admin.inc

The HTML for the message warning of incompatible modules.

theme_system_modules_uninstall

modules/system/system.admin.inc

Formats the table containing the uninstalled modules.

theme_system_powered_by

modules/system/system.module

Format the Powered by Drupal text.

theme_system_settings_form

modules/system/system.module

The HTML for the system settings form.

theme_system_themes_page

modules/system/system.admin.inc

HTML for the Theme Manager page.

Theming the Taxonomy module

The Taxonomy module enables the organization of content into categories, according to a hierarchical vocabulary.

Default Template

The Taxonomy module contains only one dedicated template.

  • taxonomy-term.tpl.php

taxonomy-term.tpl.php

Provides a template for creating a box around items. The available variables include:

Variable

Description

$classes

Classes used to provide contextual CSS styling.

$classes-array

Array of HTML class attributes, flattened into a string within the variable $classes.

$content

An array of the content of the term.

$id

Position of a term.

$is_admin

Returns True when the current user is the admin user.

$is_front

Returns True when the current page is the front page.

$logged_in

Returns True when the current user is logged in and authenticated.

$name

The name of the term.

$page

Flag indicating full page state.

$term

The full term object.

$term_url

The URL of the term.

$view_mode

The view mode (teaser, full, and so on).

$zebra

Provides an "odd/even" marker useful for styling.

Default stylesheets

There is one stylesheet dedicated to the Taxonomy module; it is located at: modules/taxonomy.

Variable

Description

taxonomy.css

Provides four selectors for the taxonomy module.

Themable functions

There are no unique themable functions in the Taxonomy module.

Theming the Toolbar module

The Toolbar module provides the admin system's toolbar functionality.

Default templates

There is no default template provided for the Toolbar module.

Default stylesheets

There is one stylesheet dedicated to the Toolbar module; it is located at: modules/toolbar.

File

Description

toolbar.css

Provides the selectors for theming the toolbar.

Themable functions

There are no themable functions dedicated to the Toolbar module.

Theming the Tracker module

The Tracker module enables the tracking of recent posts from users.

Default templates

There is no default template provided for the Tracker module.

Default stylesheets

There is one stylesheet dedicated to the Tracker module; it is located at: modules/tracker.

File

Description

tracker.css

Provides two selectors for theming the tracker table.

Themable functions

There are no themable functions dedicated to the Tracker module.

Theming the Update module

The Update module checks for available updates to the Drupal core and modules and notifies the administrator if any are available.

Default templates

There are no default templates dedicated to the update functionality.

Default stylesheets

Two stylesheets are dedicated to the formatting of the update functionality. Both are located at /modules/update.

File

Description

update.css

Numerous selectors for the update module interface in the admin system.

update-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are two themable functions associated with the update functionality. The functions can be found at: modules/update/update.report.inc, modules/update/update.module, and at modules/update/update.manager.inc.

Function

Path

Description

theme_update_last_check

modules/update/update.module

The HTML for the last time the system checked for updates.

theme_update_manager_update_form

modules/update/update.manager.inc

Formats the first page in the update manager wizard (select projects).

theme_update_report

modules/update/update.report.inc

Formats the project status report.

theme_status_label

modules/update/update.report.inc

Formats the label to display the update status.

theme_update_version

modules/update/update.report.inc

Formats the version display.

Theming the User module

Enables the user registration and login system.

Default templates

Theming the user pages is made easier in Drupal 7 through the addition of four dedicated template files:

  • user-picture.tpl.php

  • user-profile-category.tpl.php

  • user-profile-item.tpl.php

  • user-profile.tpl.php

The default templates are located at: modules/user/.

user-picture.tpl.php

Handles the presentation of the image associated with the user's account. The available variables include:

Variable

Description

$account

An array of the account information.

$user_picture

The image set by the user for the account.

user-profile-category.tpl.php

Provides a template for formatting the presentation of user profiles in category view. The available variables include:

Variable

Description

$attributes

The HTML attributes.

$profile_items

All the items for the group.

$title

The category title for the group.

user-profile-item.tpl.php

Handles the presentation of the user profile data. Loops through to present each item. The available variables include:

Variable

Description

$attributes

The HTML attributes.

$title

The field title for the profile item.

$value

The value for the profile item.

user-profile.tpl.php

Provides a template for presenting all the user data. The available variable:

Variable

Description

$user_profile

All of the user's profile data.

Default stylesheets

Two stylesheets are dedicated to the formatting of the user data. Both are located at /modules/user.

File

Description

user.css

Styles for the User module and Profile module, includes styles for user administration.

user-rtl.css

A stylesheet that is used when the site employs right-to-left text orientation.

Themable functions

There are a number of themable functions that relate to the user functionality. The functions can be found in two files: modules/user/user.module and modules/user/user.admin.inc.

Function

Path

Description

theme_user_admin_permissions

modules/user/user.admin.inc

Themes the permissions manager.

theme_user_admin_roles

modules/user/user.admin.inc

Handles the new role form.

theme_user_list

modules/user/user.module

Produces a list of users.

theme_user_permission_description

modules/user/user.admin.inc

Formats individual permission description.

theme_user_signature

modules/user/user.module

Handles the output of the user's signature.