I need help! Google is not troubleshooting my problem.
what i need to modify to hide menu when i hiding from view the term from taxonomy?
Its very important for me!!

Comments

profak’s picture

Priority: Critical » Normal
Status: Active » Fixed

I think it's more Taxonomy_Menu issue, but never the less i post solution here.
Under sponsorship of bogdanvolkov developed next solution of this task in template.php of current active theme.
Don't forget to change themename to your theme, clear cache, set BID of correct block (Taxonomy Menu).

/*
 * Implements hook_block_view_alter()
 */
function themename_block_view_alter(&$data, $block) {
  $root_tid = '';
  $child_tids = array();
  if($block->bid == 151) {
    $copy_data = $data['content'];
    foreach($copy_data as $item => $body) {
      if(is_numeric($item)) {
        # get current menu term id
        $root_tid = get_id_from_href($body['#href']);
        # get second level items if possible
        if(isset($body['#below'])) {
          foreach($body['#below'] as $id => $id_body) {
            if(is_numeric($id)) {
              $child_tids[$id] = get_id_from_href($id_body['#href']);
            }
          }
        }
        # Now we have term id ($tid) of current menu item
        # and child terms id in $child_tids
        global $user;
        $schemes = variable_get('tac_lite_schemes', 1);
        for ($i = 1; $i <= $schemes; $i++) {
          $tids  = _tac_lite_user_tids($user,$i);
          # check below items first
          if(isset($child_tids)) {
            foreach($child_tids as $delete_mlid => $delete_id) {
              if(!in_array($delete_id,$tids)) {
                 # delete all 2nd level items that are not accessible 
                 unset($data['content'][$item]['#below'][$delete_mlid]);
              }
            }
          }
          # now check current upper level tid
          if(!in_array($root_tid,$tids))
          {
            unset($data['content'][$item]);
          }
        }
      }
    }
  }
}
/**
 * Helper function get term ID from internal taxonomy path like 'taxonomy/term/18'
 */
function get_id_from_href($string) {
  $pos = strrpos($string,'/');
  $id = substr($string,$pos+1);
  return $id;
}

It looks like fixed now.

Dave Cohen’s picture

Makes sense it is a taxonomy_menu issue, because that module is probably building menu items and granting access to them statically, rather than checking per-user. A long term fix (not specific to one theme) might be to use hook_menu_alter() to change it's menu items, in particular their access callback.

Still, glad it's fixed for you and thanks for sharing that code.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

error