Моя проблема в том, что этот код также применяется к другим моим меню. Я хотел бы, чтобы Menu_item генерировал разные HTML-коды в зависимости от того, находится ли он в основном меню или нет. Я бы подумал, что проще всего это сделать с помощью оператора if в функции phptemplate_menu_item, например:
Код: Выделить всё
function phptemplate_menu_item (...){
if ($menu_name == 'primary-links')
{DO ABC}
else
{DO XYZ}
}
Спасибо!
Код: Выделить всё
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
$class = ($menu ? 'no_wrap' : ($has_children ? 'collapsed' : 'li_wrap'));
if (!empty($extra_class)) {
$class .= ' '. $extra_class;
}
if ($in_active_trail) {
$class .= ' active-trail';
}
if (!empty($link)) {
/* The following section gives the list items unique classes based on their link text - note how spaces and sepcial chars are removed */
// remove all HTML tags and make everything lowercase
$css_id = strtolower(strip_tags($link));
// remove colons and anything past colons
if (strpos($css_id, ':')) $css_id = substr ($css_id, 0, strpos($css_id, ':'));
// Preserve alphanumerics, everything else goes away
$pattern = '/[^a-z]+/ ';
$css_id = preg_replace($pattern, '', $css_id);
$class .= ' '. $css_id;
}
// the following code returns the menu item formatted in a different fashion depending on the class of the item. The first one is for items with a class of none - ie the space li at end of menu
if (strstr($class, 'none')) {
return '[*]';
}
if (strstr($class, 'li_wrap')) {
return '[*]'. $link . $menu ."\n";
}
if (strstr($class, 'no_wrap')) {
return '[*]'. $link ."". $menu ."\n";
}
Подробнее здесь: https://stackoverflow.com/questions/835 ... enu-name-t