diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-08-02 20:08:53 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-08-02 20:08:53 +0000 |
commit | c70b19a91bfedbae40304cbfed7b5875c5aae342 (patch) | |
tree | b237cd93f51090265af063ffb54b1730f9e33eec /includes | |
parent | bb7d1395bc0bc7eafc3a2ba5a410ed35978ba9a6 (diff) | |
download | brdo-c70b19a91bfedbae40304cbfed7b5875c5aae342.tar.gz brdo-c70b19a91bfedbae40304cbfed7b5875c5aae342.tar.bz2 |
- Patch #163723 by Eaton and Frando: fix default page.tpl markup (and removed some whitespace).
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 4 | ||||
-rw-r--r-- | includes/theme.inc | 33 |
2 files changed, 33 insertions, 4 deletions
diff --git a/includes/common.inc b/includes/common.inc index c07fc1bee..bd81a54bd 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -2650,10 +2650,6 @@ function drupal_common_themes() { 'help' => array( 'arguments' => array(), ), - 'node' => array( - 'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE), - 'file' => 'node', - ), 'submenu' => array( 'arguments' => array('links' => NULL), ), diff --git a/includes/theme.inc b/includes/theme.inc index f778fe262..b4ef05708 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1611,6 +1611,7 @@ function template_preprocess_page(&$variables) { $variables['layout'] = $layout; global $theme; + global $user; // Populate the rest of the regions. $regions = system_region_list($theme); // Load all region content assigned via blocks. @@ -1661,6 +1662,38 @@ function template_preprocess_page(&$variables) { $variables['node'] = node_load(arg(1)); } + // Compile a list of classes that are going to be applied to the body element. + // This allows advanced theming based on context (home page, node of certain type, etc.). + $body_classes = array(); + // Add a class that tells us whether we're on the front page or not. + $body_classes[] = (drupal_is_front_page()) ? 'front' : 'not-front'; + // Add a class that tells us whether the page is viewed by an authenticated user or not. + $body_classes[] = ($user->uid > 0) ? 'logged-in' : 'not-logged-in'; + // Add arg(0) to make it possible to theme the page depending on the current page + // type (e.g. node, admin, user, etc.). To avoid illegal characters in the class, + // we're removing everything disallowed. We are not using 'a-z' as that might leave + // in certain international characters (e.g. German umlauts). + $body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-' . form_clean_id(drupal_strtolower(arg(0)))); + // If on an individual node page, add the node type. + if (isset($variables['node']) && $variables['node']->type) { + $body_classes[] = 'node-type-'. form_clean_id($variables['node']->type); + } + // Add information about the number of sidebars. + if ($variables['sidebar_left'] && $variables['sidebar_right']) { + $body_classes[] = 'two-sidebars'; + } + elseif ($variables['sidebar_left']) { + $body_classes[] = 'one-sidebar sidebar-left'; + } + elseif ($variables['sidebar_right']) { + $body_classes[] = 'one-sidebar sidebar-right'; + } + else { + $body_classes[] = 'no-sidebars'; + } + // Implode with spaces. + $variables['body_classes'] = implode(' ', $body_classes); + // Build a list of suggested template files in order of specificity. One // suggestion is made for every element of the current path, though // numeric elements are not carried to subsequent suggestions. For example, |