I'm trying to override the way that menu items are displayed. I have the following function :
function newtheme_item_list($items = array(),$title=NULL,$type='ul',$attributes=NULL)
{
$positions = array("","second","third","forth");
if (!empty($items)) {
$output .= "<$type" . drupal_attributes($attributes) . '>';
foreach ($items as $item_key=>$item) {
$attributes = array();
$children = array();
if (is_array($item)) {
foreach ($item as $key => $value) {
if ($key == 'data') {
$data = $value;
}
elseif ($key == 'children') {
$children = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$data = $item;
}
if (count($children) > 0) {
$data .= theme_item_list($children, NULL, $type, $attributes); // Render nested list
}
if ($item_key > 0)
{
$attributes['class'] = ' nav_separator '.$positions[$item_key].'-nav';
}
if($item_key == 0) {
$attributes['class'] = 'first-nav';
}
elseif($item_key == count($items)-1){
$attributes['class'] = ' last-nav';
}
$output .= '<li' . drupal_attributes($attributes) . '>'. $data .'</li>';
}
$output .= "</$type>";
}
$output .= '</div>';
return $output;
}
In the page.inc.php i have the line:
print theme('links', array('links' => menu_navigation_links('main-menu'),'attributes' => array('class'=> array('links', 'site-menu'))));
This it should add some different classes to my menu but instead i get this error:
Recoverable fatal error: Argument 1 passed to drupal_attributes() must be an array, null given, called in D:\EasyPHP-5.3.5.0\www\drupal\themes\newtheme\template.php on line 12 and defined in drupal_attributes() (line 2301 of D:\EasyPHP-5.3.5.0\www\drupal\includes\common.inc).