diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-07-07 20:18:22 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-07-07 20:18:22 +0000 |
commit | 3568ed57e1fc0b0a46ad683b529ea5823a7b78d4 (patch) | |
tree | 2a7271215466e90c67bca910bde224e9f405c8cf /modules/taxonomy.module | |
parent | bddcee534fb666890d82089742ec709a718588dc (diff) | |
download | brdo-3568ed57e1fc0b0a46ad683b529ea5823a7b78d4.tar.gz brdo-3568ed57e1fc0b0a46ad683b529ea5823a7b78d4.tar.bz2 |
- Moving the title.module from core to contrib as discussed on the mailing list.
Diffstat (limited to 'modules/taxonomy.module')
-rw-r--r-- | modules/taxonomy.module | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 1f18319d0..cb7ff9e56 100644 --- a/modules/taxonomy.module +++ b/modules/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") .'<br />'. 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'); |