Hello Drupal Community,

I use Zen to design a project site.

I wanted to use the page.tpl.php file to modify the layout. my general problem now is, that the variable $body_classes does not print out any classes. Only if i am logged in the class "admin menu" (from the module) is shown.

i use the following statement in the body tag of the template:

">

after searching for a while i found out that the $body_classes variable is defined in the template_preprocess_page in /includes/theme.inc. The function has not been modified and the functions for the body_classes look like this:

  $body_classes = array();
  // Add a class that tells us whether we're on the front page or not.
  $body_classes[] = $variables['is_front'] ? 'front' : 'not-front';
  // Add a class that tells us whether the page is viewed by an authenticated user or not.
  $body_classes[] = $variables['logged_in'] ? '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['layout'] == 'both') {
    $body_classes[] = 'two-sidebars';
  }
  elseif ($variables['layout'] == 'none') {
    $body_classes[] = 'no-sidebars';
  }
  else {
    $body_classes[] = 'one-sidebar sidebar-'. $variables['layout'];
  }
  // Implode with spaces.
  $variables['body_classes'] = implode(' ', $body_classes);

other changes that i make in the page.tpl file are applied correctly. but my body class still looks empty - no matter what i do.

my drupal version is 6.2 and i use zen 2.0

thank you a lot for the support.

Comments

Kaesebaellchen’s picture

Assigned: Kaesebaellchen » Unassigned
silverfly’s picture

Make sure you have copied Zen's starterkit template.php file into your sub theme and have modified it for your theme.

The starterkit template file can be found in .../Zen/STARTERKIT/template.php -> copy that into your sub theme's root folder.

Then open that file, and rename the only function it has to your theme's name.

function STARTERKIT_theme(&$existing, $type, $theme, $path) -> replace STARTERKIT with your theme's name.

wiredescape’s picture

Don't forget to also edit the theme-settings.php file.

From the README.txt in the STARTERKIT:

4. Edit the template.php and theme-settings.php files in your sub-theme's
folder; replace ALL occurrences of "STARTERKIT" with the name of your
sub-theme.

For example, edit foo/template.php and foo/theme-settings.php and replace
every occurrence of "STARTERKIT" with "foo".

It is recommended to use a text editing application with search and
"replace all" functionality.

shruti.sheth’s picture

Component: PHP Code » layout.css

Hi,

I made a custom theme of zen 6.x-2.0 version, and I was able to get the $body_classes printed for the same.

Please try the following steps.
1. copy zen/STARTERKIT in your custom theme directory.
2. Move the STARTERKIT to your theme name e.g. my_theme
3. Rename STARTERKIT.info.txt to my_theme.info
-> in the info file change name = Zen Sub-theme Starter Kit
to
name =my_theme
4. in your template.php and theme-settings.php replace STARTERKIT with my_theme
5. Please copy all the templates from zen/templates to your custom my_theme teplates directory.

Thanks.

izkreny’s picture

Maybe this line from 6.x-2.0 release info could help:

Renamed page.tpl's $body_classes and $body_classes_array to $classes and $classes_array
johnalbin’s picture

Status: Active » Closed (fixed)