In block, how to find out current category?
jasonmcmunn - November 14, 2004 - 18:59
I'm making a module that will make a few blocks. I want the content of the blocks to very based on what the category of the current focused item is. For instance, if there is a story about cats on the main page, i want the auxillary blocks to have information about cats. How do I tell in the sidebar if the main main item has changed?
help!
thanks!

this is really exciting, i've
this is really exciting, i've been looking for a module like this! :)
have you got an eta?`
:water
nodeapi hook
Your module should implement the nodeapi hook and look for nodes where $op == "view". Each node may contain an array of terms ($node->terms) that lists the category term ids for each node. If you were to collect a list of these terms in a local static variable, you could use this as the list of all terms currently being displayed on a page and construct your list of blocks accordingly.
So, if your module maintained a mapping between taxonomy (category) terms and block content, you could use the list of terms derived above to create you list of blocks. You'll definitely want to study how the taxonomy module works for developing the administrative interface (specifically, look at taxonomy_get_vocabularies and taxonomy_form functions).
No terms?
I grabbed the node object and stashed it just like you said. I can pull out the nid, but I don't see terms. Do i have to manually load the object off of the nid?
thanks! this has really helped me out immensely.
Other things i've tried:
$terms = module_invoke('taxonomy', 'node_get_terms', $mynode->nid, 'tid');
$test4 = $mynode->terms[0];
$terms2 = taxonomy_node_get_terms($mynode->nid);
$test5 = $terms2[0];
Nevermind! When I went throug
Nevermind! When I went through it with foreach, i found my data. Thanks so much!
Hello, I was just wondering
Hello, I was just wondering how the development on this module was going.
This module is one of many factors I need in place to migrate to drupal, that's why i'm interested.
:christoffer lie syversen.