开发者

How can count the children of Drupal's main menu?

Is there a possibility to get the number of children of the main menu in Drupal (7)? I need to implement it in this part of the hook:

  if($item_id < NUMBER OF MAIN MENU CHILDS) {
  return '<li id="cus开发者_开发技巧tom-menu-item-id-' . (++$item_id) . '"' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
  }
  else {
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
  }

This menu doesn't contain any subitems, but with children I mean every 'li' attribute.


You can use menu_tree_page_data:

$num_top_level_children = count(menu_tree_page_data('main-menu'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜