Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Good day.
I can't understand some questions. Please help me.
____________________________________________________________________
I'm using 7-x -3.1 version.
I'm created subtheme based on the at_subtheme.
I'm renamed It to ecomotors.
In my template.php I'm putting this code:
function ecomotors_preprocess_html(&$variables) {
$roles_array = $variables['user']->roles;
if (in_array("administrator", $roles_array)) {
$variables['classes_array'][] = 'is-admin';
}
else {
$variables['classes_array'][] = 'not-admin';
}
}
But they are not applied in my body class in page.
My function ecomotors_breadcrumb works greate, but function ecomotors_preprocess_html dont applied on the page.
Comments
Comment #1
Jeff Burnz CreditAttribution: Jeff Burnz commentedThat should work, did you clear the cache?
Just remember body classes are not in the "page" in Drupal, they are in the html.tpl.php template, strictly speaking "page" classes are in the page.tpl.php template and uses the themeName_preprocess_page() function (unlike most themes AT actually makes use of the page template level classes array).
I assume when you say "body classes" you mean classes applied to the "body" element, in which case what you have above is correct.
Comment #2
Jeff Burnz CreditAttribution: Jeff Burnz commentedAssuming fixed.