I am trying to build a Drupal site that changes the background depending on what section of the site a visitor is looking at. I have some child pages that should inherit the parent page's background.
I am doing this by adding a class to the BODY tag, and specifying the background in CSS through that class.
Everything works, but I nevertheless get the following error:
Notice: Undefined offset: 1 in MYTHEME_preprocess_html() (line 23 of template.php)
I am using the following code to detect what section of the site is active, and to add a sanitized version of the parent page as a CSS class:
function MYTHEME_preprocess_html(&$variables) {
$menuParent = menu_get_active_trail();
$menuParent = drupal_html_class($menuParent[1]['link_title']);
$variables['classes_array'][] = $menuParent;
As I said, it works, the backgrounds display correctly, but the error is with the line:
$menuParent = drupal_html_class($menuParent[1]['link_title']);
This is perplexing because the code works and [1] is populated with a host of values, which I can see using:
print_r ($menuParent[1]);
print_r returns:
Array
(
[menu_name] => main-menu
[mlid] => 298
[plid] => 0
[link_path] => node/1
[router_path] => node/%
[link_title] => Motion Pictures
[options] => Array
(