Display total Nodes within each Term ??
HanleyDesigns - May 19, 2009 - 04:09
| Project: | Links Package |
| Version: | 6.x-2.x-dev |
| Component: | Code: links_weblink.module |
| Category: | feature request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
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);}
?>
#1
can anybody please help? thanks :)
#2
I really Need This too... preferrably in the form of views... which can list the taxonomy terms and filter/sort them....!!!