My weblink Taxomony is hierarchical and I noticed that the totals of weblinks in the weblink/view are not hierarchical. Example will show you:

Links
- International (0)
- National (0)
-- My state (1)
--- A link to a site in my state

In my example National shows (0) like in the actual view page, but in fact there is one link in National under My state and therefore National should be (1).

I hope you agree with my logic.

Comments

Uwe Hermann’s picture

Anonymous’s picture

same problem, ne fixes yet?

stelman’s picture

Anonymous’s picture

I think i managed to fix this. Phew, that took some work ( and I got to learn a lot about drupal :) ). You need to change one of the functions.
Disclaimer: I dont know how good this hack is so use at your own risk :P

Here is the function. Will someone else check if this is okay and make the patch of whatever.

function _weblink_get_structure($tid = 0) {
  // this structure is a good candidate for caching
  $categories = taxonomy_get_children($tid, variable_get("weblink_nav_vocabulary", ""));
  
  foreach (array_keys($categories) as $term_id) {
    $terms = array();
    $children = taxonomy_get_tree(variable_get("weblink_nav_vocabulary", ""), $term_id);
    $terms[] = $term_id;
    foreach ($children as $term) {
      $terms[] = $term->tid;
    }
    $result = db_query("SELECT COUNT(*) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND tid IN (". implode(",", $terms) .") AND n.type = 'weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql());
    $children = taxonomy_get_children(variable_get("weblink_nav_vocabulary", ""), $term_id);
    foreach ($children as $term) {
      $categories[$term_id]->subterms[$term->tid] = $term->name;
    }
    while ($term = db_fetch_object($result)) {
      $categories[$term_id]->link_count = $term->c;
    }
  }
  
  return $categories ? $categories : array();
}

from this

function _weblink_get_structure($tid = 0) {
  // this structure is a good candidate for caching
  $categories = taxonomy_get_children($tid, variable_get("weblink_nav_vocabulary", ""));
  $tree = taxonomy_get_tree(variable_get("weblink_nav_vocabulary", ""));
  
  foreach (array_keys($categories) as $term_id) {
    $terms = array();
    $children = taxonomy_get_tree(variable_get("weblink_nav_vocabulary", ""), $term_id, 1);
    $terms[] = $term_id;
    foreach ($children as $term) {
      $terms[] = $term->tid;
      $categories[$term_id]->subterms[$term->tid] = $term->name;
    }
    $result = db_query("SELECT COUNT(*) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND tid IN (". implode(",", $terms) .") AND n.type = 'weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql());
    while ($term = db_fetch_object($result)) {
      $categories[$term_id]->link_count = $term->c;
    }
  }
  
  return $categories ? $categories : array();
}

U can check it out here
test

Bèr Kessels’s picture

we no longer have a browse interface. Use the directory module instead.