You are here

function _taxonomy_menu_update_link_items in Taxonomy menu 7

Same name and namespace in other branches
  1. 6.2 taxonomy_menu.module \_taxonomy_menu_update_link_items()

Updates the menu items.

Parameters

$vid: Vocabulary ID.

2 calls to _taxonomy_menu_update_link_items()
taxonomy_menu_overview_submit in ./taxonomy_menu.module
Submit handler, reacting on form ID: taxonomy_overview_terms.
taxonomy_menu_vocab_submit in ./taxonomy_menu.module
Submit handler for the extra settings added to the taxonomy vocab form.

File

./taxonomy_menu.module, line 309
Adds links to taxonomy terms into a menu.

Code

function _taxonomy_menu_update_link_items($vid) {
  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $vid), FALSE);
  $depth = variable_get(_taxonomy_menu_build_variable('max_depth', $vid), 0);

  // Get a list of the current tid - menu_link combinations.
  $menu_links = _taxonomy_menu_get_menu_items($vid);

  // Cycle through the menu links.
  foreach ($menu_links as $tid => $mlid) {
    if (!_taxonomy_menu_term_too_deep($tid, $depth)) {

      // $args must be reset each time through.
      $args = array(
        'menu_name' => $menu_name,
        'mlid' => $mlid,
      );
    }
    if ($tid == 0) {
      $args['vid'] = $vid;
    }
    else {
      $args['term'] = taxonomy_term_load($tid);
    }

    // Update the menu link.
    taxonomy_menu_handler('update', $args);
  }
  return t('The Taxonomy Menu %menu_name has been updated.', array(
    '%menu_name' => $menu_name,
  ));
}