_menu_update_parental_status
function _menu_update_parental_status
_menu_update_parental_status($item, $exclude = FALSE)
Checks and updates the 'has_children' status for the parent of a link.
Related topics
File
- includes/menu.inc, line 3563
- API for the Drupal menu system.
Code
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'); $query->addField('menu_links', 'mlid'); $query->condition('menu_name', $item['menu_name']); $query->condition('hidden', 0); $query->condition('plid', $item['plid']); $query->range(0, 1); if ($exclude) { $query->condition('mlid', $item['mlid'], '<>'); } $parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0; db_update('menu_links') ->fields(array('has_children' => $parent_has_children)) ->condition('mlid', $item['plid']) ->execute(); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!menu.inc/function/_menu_update_parental_status/7.x