The subcategories links in the default weblink page are incorrects because of the use of array_slice($terms) in _weblink_get_category.
array_slice reset the $terms' numeric keys which are filled with $tid, so the subcategories are wrongly linked 0, 1, 2 ...
I solve it by replacing array_slice($terms) with unset($terms($tid)) , $terms($tid) is the first item.

And sorry, I don't know yet how to make a patch. (This is my first contribute to the open source, woohoo!)

CommentFileSizeAuthor
#4 weblink_AlSquire.patch837 bytesjunyor

Comments

junyor’s picture

If you can post the code changed (see the "Formatting guidelines" below the comment form), someone else can probably make the appropriate patch.

FYI, there's a good bit of information in the Drupal handbook about making patches and working with CVS. See http://drupal.org/node/316 for some links.

AlSquire’s picture

The _weblink_get_category function now is :

function _weblink_get_category($tid) {
  $children = taxonomy_get_tree(variable_get("weblink_nav_vocabulary", ""), $tid, 1);
  $terms = array($tid => '');
  foreach ($children as $term) {
    $terms[$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(",", array_keys($terms)) .") AND n.type = 'weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql());
  $term = db_fetch_object($result);
  array_shift($terms);
  return array($terms, $term->c, count(_taxonomy_term_children($tid)));
}

As explained above, the use of array_shift is bad, so I just use unset instead :

function _weblink_get_category($tid) {
  $children = taxonomy_get_tree(variable_get("weblink_nav_vocabulary", ""), $tid, 1);
  $terms = array($tid => '');
  foreach ($children as $term) {
    $terms[$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(",", array_keys($terms)) .") AND n.type = 'weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql());
  $term = db_fetch_object($result);
  unset($terms[$tid]);
  return array($terms, $term->c, count(_taxonomy_term_children($tid)));
}
AlSquire’s picture

Oops, I've just figured that I was talking about array_slice instead of array_shift in my first post :p
Although the second one is correct.

junyor’s picture

StatusFileSize
new837 bytes

In that case, I *think* this is the patch you wanted to make.

AlSquire’s picture

Thank you :)

joho’s picture

Beautiful! I just ran into this problem and there's a _lot_ of content that depends on it.
:-)

Bèr Kessels’s picture

Status: Needs review » Closed (won't fix)

weblinks ahs long since abandoned the directory display.