Drupal equivalent of WordPress' page templates I'm developing my first Drupal site, having built my CMS experience on WordPress. I've managed to wrap my head around many of Drupal's paradigms, but I can't figure out how Drupal accomplishes the functionality of page templates in WordPress.

By "page templates" I mean the option in WordPress to set a specific template (written in PHP) to use for a given page:



For reference, I use the templates in multi-site deployments to create standardized pages for subsites (e.g. "contact", "about us"), but a subsite has the ability to disable the template and create their own content.

What would be the best practice to accomplish this?
There are several ways to suggest/override theme of a page in Drupal. 

1. Override core theme files:

Firstly there are core themes defined by Drupal, which can be overridden from your theme. For example, the default user profile page uses user-profile.tpl.php. Though this is defined in Drupal Core, you can override it by copying it to your theme folder and modifying. The list of core file can be found here. 

2. Default Theme Suggestions in Core

Drupal has implemented some default theme suggestion patterns in the core. It helps us write a specific theme for a page, path or even a particular article without having to write code. For example, if your about page has a node id 1. You write a template for just that page by creating a template file page--node--1.tpl.php in your theme folder. Similarly, you can suggest a theme for a node, user, block etc.  You can see available core suggestions in this page under respective heading. 

3. From UI using context module:

Context module allows you to manage contextual conditions and reactions for different portions of your site. You can, for example, choose 1 or more conditions like path, user type etc and then add theme suggestion as a reaction to that condition/s. 


Using context module.
Also, see ThemeKey module.


4. From code:
You can also write custom theme suggestion based on your own logic from code, either in template.php file of your template from a custom module. 

An example from documentation:

// Add a single suggestion for nodes that have the "Promoted to front page" box checked.

function drop_preprocess_node(&amp;$variables) {
  if ($variables['promote']) {
    // looks for node--promoted.tpl.php in your theme directory
    $variables['theme_hook_suggestions'] = 'node__promoted';
  }
}


A lot of code example can be seen if you scroll a bit down on this page.

Additionally, change the theme debug settings in setting.php to get additional information in HTML markup with respect to the theme. The setting to change is $conf['theme_debug'] = TRUE;. Once done, you'll get a lot of valuable suggestion in the HTML markup of each page.