Download & Extend

Display total Nodes within each Term ??

Project:Links Package
Version:6.x-2.x-dev
Component:Code: links_weblink.module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I would like to display next to the subcategory the total number of 'nodes' within each 'term'. The webpage that this needs to go into is located here: http://www.bigfreelinks.com/links/weblink
Any help doing this would be greatly appreciated!!! :)

e.g.
Antiques (42)
Books (13)
Comics (7)

This is the section of code that needs to be edited to make this work:

function theme_links_weblink_category_children($children) {
  $kids = "";
  foreach ($children as $i=>$kid) {
    if (is_int($i)) {
      $kids .= drupal_render($kid);
    }
  }

I have tried to change it myself, but I'm no PHP expert... I did find a bit of code posted on here that does a similar thing... see below (maybe parts of this code can be added to the code above??)

<?php

$vid
= 1// Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$items = array();
$terms = taxonomy_get_tree($vid);
foreach (
$terms as $term ) { 
   
$count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid)); 
   
$items[] = l($term->name, "taxonomy/term/$term->tid") . " ($count)";
}
if (
count($items) ) {  print theme('item_list', $items);}
?>

Comments

#1

can anybody please help? thanks :)

#2

Priority:normal» critical

I really Need This too... preferrably in the form of views... which can list the taxonomy terms and filter/sort them....!!!

#3

Priority:critical» normal
Status:active» closed (fixed)

I just made links that look exactly like "Antiques (42)" counting the number of nodes for a taxonomy term, using this module: http://drupal.org/project/term_node_count

Worked like a charm.

Closing this since no activity in a long time and I think this is the answer best I can tell.