function _menu_update_parental_status

Checks and updates the 'has_children' status for the parent of a link.

Related topics

3 calls to _menu_update_parental_status()
menu_link_save in drupal/includes/
Saves a menu link.
_menu_delete_item in drupal/includes/
Deletes a single menu link.
_menu_link_move_children in drupal/includes/
Updates the children of a menu link that is being moved.


drupal/includes/, line 3564
API for the Drupal menu system.


function _menu_update_parental_status($item, $exclude = FALSE) {

  // If plid == 0, there is nothing to update.
  if ($item['plid']) {

    // Check if at least one visible child exists in the table.
    $query = db_select('menu_links');
      ->addField('menu_links', 'mlid');
      ->condition('menu_name', $item['menu_name']);
      ->condition('hidden', 0);
      ->condition('plid', $item['plid']);
      ->range(0, 1);
    if ($exclude) {
        ->condition('mlid', $item['mlid'], '<>');
    $parent_has_children = (bool) $query
      ->fetchField() ? 1 : 0;
      'has_children' => $parent_has_children,
      ->condition('mlid', $item['plid'])