It appears that if I select a vocabulary id when configuring my block I will not get all node items listed correctly.

This appears to be caused by the vocab id (vid) being passed to the taxonomy_get_children() as both the vid AND the tid value. So I only ever see nodes which have a term id = vocab id.

Looking through the taxonomy.module there doesn't appear to be a documented way to obtain all term ids belonging to a vocabulary id.

The following code will obtain all the term ids and put them in an array.

 // Get terms in this vocabulary
      $result = db_query('SELECT t.* FROM {term_hierarchy} h, {term_data} t WHERE t.vid = %d AND h.tid = t.tid ORDER BY weight, name', $vid);
      $tids = array();
      while ($term = db_fetch_object($result)) {
        $tids[] = $term->tid;
      }

Maybe it can be used somewhere in the taxonomy_block.module ?

CommentFileSizeAuthor
#1 vocab.patch825 bytesbudda

Comments

budda’s picture

Status: Active » Needs review
StatusFileSize
new825 bytes

Fix wasn't so difficult after all.

Tested with a vocabulary and child terms, and a vocab with a multiple hierarchy of terms.

Results as expected.

I wasn't 100% clear what the point of $tids[$result->tid] = $result->tid; was, so moved it to only be used when creating a list of child terms from a selected root term.

budda’s picture

Assigned: Unassigned » budda
Status: Needs review » Fixed

Patch applied yesterday.

Anonymous’s picture

Status: Fixed » Closed (fixed)