Hey guys,

I need to have an additional body class if some messages or errors are on the current page.
I used hook_preprocess_html in template.php for adding a "slider" class if something is in slider region, but i dont know how to check for messages?

function THEME_preprocess_html(&$variables) {
  if (!empty($variables['page']['slider'])) {
	$variables['classes_array'][] = 'slider';
  }
}

The only thing i found is $variables['page']['#show_messages'] but this is alwas true, think it means only if messages are turned on or off, right?

I need this to style some elements different if there are errors on the page.

Cheers Can

Comments

ipwa’s picture

In your page--front.tpl.php

do something like this in the wrapper div:

<div class="page-wrap <?php if ($messages): ?>messages<?php endif; ?>">

Nicolas
-------------------------

jaypan’s picture

if(drupal_get_messages(NULL, FALSE))
{
  $variables['classes_array'][] = 'messages_exist';
}

Contact me to contract me for D7 -> D10/11 migrations.