Simplified creation of page- and section- body classes.
authorJohnAlbin
Sun, 20 Jan 2008 07:25:31 +0000 (07:25 +0000)
committerJohnAlbin
Sun, 20 Jan 2008 07:25:31 +0000 (07:25 +0000)
template.php

index 3f9b9fa..ed81ddb 100644 (file)
@@ -220,19 +220,9 @@ function _phptemplate_variables($hook, $vars = array()) {
       }
       if (!$vars['is_front']) {
         // Add unique classes for each page and website section
-        // First, remove base path and any query string.
-        global $base_path;
-        list(,$path) = explode($base_path, $_SERVER['REQUEST_URI'], 2);
-        // If clean URLs are off, strip remainder of query string.
-        list($path,) = explode('&', $path, 2);
-        // Strip query string.
-        list($path,) = explode('?', $path, 2);
-        $path = rtrim($path, '/');
-        // Construct the id name from the path, replacing slashes with dashes.
-        $full_path = str_replace('/', '-', $path);
-        // Construct the class name from the first part of the path only.
+        $path = drupal_get_path_alias($_GET['q']);
         list($section,) = explode('/', $path, 2);
-        $body_classes[] = zen_id_safe('page-'. $full_path);
+        $body_classes[] = zen_id_safe('page-'. $path);
         $body_classes[] = zen_id_safe('section-'. $section);
       }
       $vars['body_classes'] = implode(' ', $body_classes); // implode with spaces