In this video we introduce the template.php file and create our first preprocess function. We explain what the preprocess hooks are and how to name the function properly, then we show a list of existing variables, and how to modify one of those existing variables.
Additional resources
This chapter explains hook_page_alter(), which is another alter hook new to Drupal 7 and to the theme layer. Each page rendered by Drupal is contained within an array where the theme is able to go in and rearrange, delete or duplicate specific page elements.
Additional resources
This video walks through the new interface in Drupal 7 for enabling themes, setting them to be the default, and configuring the administration theme. It also walks through the process of downloading a contributed theme, and where to store it. Finally, it walks through the theme settings pages that provide a user interface for turning on and off specific options for a theme.
Additional resources
There are four alter hooks that are now available to the theme layer in Drupal 7. This chapter walks through two of those hooks, hook_css_alter() and hook_js_alter(). These hooks allow the theme layer to reorder, delete or replace specific CSS or JavaScript files that are being loaded by Drupal core or other contributed modules.
Additional resources
Continuing on our work with preprocess functions, we look at how to add a new variable for our template files to use. We also see how to change the output based on whether the user is logged in or not, and how to add a variable to the t() function.
Additional resources
In this video we will look at how to add CSS and JavaScript to our site using drupal_add_css()
and drupal_add_js()
. We will also show using these functions to conditionally add the CSS and JavaScript, within our page preprocess function.
Additional resources
Omega is a Drupal base theme that provides you with a really nice responsive framework. Omega also provides a lot of configuration options that are accessed through the UI rather than code. So, you can adjust the display settings and know that the underlying framework will be intact.
In this series, we're going to be demonstrating the Omega module by converting an existing Drupal theme into an Omega sub-theme. We'll talk about the HTML and CSS that's involved, and how they work together. We'll be working with theme functions and looking at the Omega best practices around how to break out your theme functions, where to put those, and how to use them.
Additional resources
In this video we will look at overriding a theme function instead of working with the template files. We will be modifying the breadcrumb using theme_breadcrumb(). to do this we'll use the Theme Developer module to help us find what we're looking for, and then we'll walk through how to override.
Additional resources
Theme Developer module (Drupal.org)
960 Robots
Takes a tour through some of the more useful template variables, and more ways of determining the available variables by adding the following code to a page template:
We'll go a step further with our preprocess functions and look at working with node variables, and how to limit new variables to only specific content types.
Additional resources
In this video we'll see how we can create our own template suggestions. We'll do this in our node preprocess function to create a new node template that will be used depending on the day of the week.
Additional resources
Markup in Drupal
CourseIn this lesson we're going to take a look at the Omega theme, cover some basic terminology around it, and discuss the advantages and challenges of using it. Specifically this lesson will cover:
- Omega features
- Helper modules
- Where to find documentation
- Omega terminology
Additional resources
- Omega theme
- Omega Tools module
- Delta module
- Omega Handbook
This chapter gives an introduction to how you work with Drupal's renderable, form arrays by adding an image button to the search form. It also walks through the process of adding the necessary classes to a form element so that the image button is properly aligned. The Forms API reference document is a pretty essential reference document for creating and editing forms in Drupal.
Although we use the function dsm() in this video, this should probably be dpm() as that's the preferred function name. The functions dsm() and dpm() are identical.
Additional resources
This lesson goes through the process of creating Theme Settings so that administrators of a theme are able to turn on and off specific features within the the theme, as well as specify other relevant settings.
Note: Twitter has recently shut down their v1 REST API so this lesson's site_slogan adjustment no longer works (it will always return no values because there is no API data found). The core concepts of how to create theme settings are still correct, you just won't be able to see the output from Twitter.
Additional resources
Field Templates
FreeIn this lesson we cover how you can do some powerful things with Display Suite in regards to field templates. Using the Display Suite GUI there are lots of configurations and offerings to get the markup just the way you want.
Additional resources
In this tutorial, we'll download the Theme Developer module and use it to inspect our view when it is using view modes for display instead of fields. We'll also look at how Theme Developer interacts with Views and some of the "gotchas" that can occur when using these modules together.
Additional resources
Theme Developer — Drupal.org
Devel — Drupal.org
simplehtmldom API — Drupal.org
PHP
TopicPHP: Hypertext Preprocessor (PHP) is a popular interpreted programming language that is especially suited for web development. Drupal core and all contributed modules are written in PHP.