From 3568ed57e1fc0b0a46ad683b529ea5823a7b78d4 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 7 Jul 2004 20:18:22 +0000 Subject: - Moving the title.module from core to contrib as discussed on the mailing list. --- modules/taxonomy/taxonomy.module | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'modules/taxonomy/taxonomy.module') diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 1f18319d0..cb7ff9e56 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -74,6 +74,29 @@ function taxonomy_menu() { return $items; } +/** + * Implementation of hook_block(). + * + * Generates a block with all categories. + */ +function taxonomy_block($op = 'list', $delta = 0) { + if ($op == 'list') { + $blocks[0]['info'] = t('Categories'); + return $blocks; + } + else if (user_access('access content')) { + $result = db_query("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid ORDER BY updated DESC, d.name"); + $items = array(); + while ($category = db_fetch_object($result)) { + $items[] = l("$category->name ($category->count)", "taxonomy/page/or/$category->tid") .'
'. format_interval(time() - $category->updated) .' '. t('ago'); + } + + $block['subject'] = t('Categories'); + $block['content'] = theme('item_list', $items); + return $block; + } +} + function taxonomy_form_vocabulary($edit = array()) { foreach (node_list() as $type) { $nodetypes[$type] = node_invoke($type, 'node_name'); -- cgit v1.2.3