If I add or update a node linked to a child term, the parent menu -item does not get updated while it may change if "Display number of items" is checked (as well as "Use 'all' at the end of URL") (or if "Hide empty terms" is checked)

Example:
Menu looks like:
term 1 (3)
- term 1.1 (2)
- term 1.2 (1)
term 2 (4)

If I add a node tagged with term 1.1 the updated menu should look like:
term 1 (4)
- term 1.1 (3)
- term 1.2 (1)
term 2 (4)

I quickly solved it by adding the following lines (no guarantee that it works for all combinations of settings)

function _taxonomy_menu_nodeapi_helper($op, $terms = array()) {
  $org_op = $op; // NEW LINE
  foreach ($terms as $key => $tid) {
    ...
    if ($menu_name && $vocb_sync && ($menu_num || $hide_empty)) {
      switch ($op) {
        ...
      }
      taxonomy_menu_handler($op, $args);
      // NEW LINES: update parent menu items as well if display_num or hide_empty
      foreach ($term->parents as $parent) {
        _taxonomy_menu_nodeapi_helper($org_op, array($parent));
      }
      // END OF NEW LINES
    }
  }
}

Comments

dstol’s picture

Status: Active » Needs review
dstol’s picture

Status: Needs review » Needs work

It'd be really helpful if you were able to create a patch for this. http://drupal.org/patch/create

johnv’s picture

Component: Sync or Update Issues » Sync
Status: Needs work » Closed (duplicate)