Добавление значков для ссылок в меню



Этот код будет создавать уникальный ID для каждого пункта меню, что позволит применять CSS, jQuery и др. только к конкретному пункту. Добавьте этот код в файл template.php.

<?php
function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
 
$link = menu_item_link($mid);
 
$css_id = strtolower(str_replace(' ', '_', strip_tags($link)));
  return
'<li id="' . $css_id . '" class="' . ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. $link . $children ."</li>\n";
}
?>

Пример использования CSS (добавление значка):

li#my_account a{
background-image:url(../mytotallysweeticons/my_account.png);
}

Этот документ, упрощённая версия документа написанного Nick Lewis.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.