Ok, I am quite new to drupal, so please forgive me if I am missing something elementary. However, I am looking through module source code, the API docs, and this forum, and still haven't found an answer to my problem.
I want to create a module that will produce context-sensitive content in a block in the right-hand column. I am using a taxonomy to assign each node to a content hierarchy. For each node, then, I want to produce sidebar content that is related to it through the taxonomy terms. I would like to configure this like other blocks -- i.e., enable the module, enable the block, and tell it to go on the right.
As far as I can tell, I need to get the current node object to get its terms. But, I can't figure out how to identify the current node without having to parse the URL, and I can't help but think that that seems like a hack. Is this really the best/only way? I have read through a number of other forum posts that express the same sorts of issues, but the solutions all divert from the original intent. My apologies if, in my travels, I simply haven't found the one, true post that contains my answer -- if you know where it is, please let me know!
My compromise right now is to not treat it like other blocks. In my template code, I am just making a call to:
<?php
// the context-sensitive stuff
print mysidebar_display($node);
// the normal sidebar
print $sidebar_right;
?>
This seems less comfortable to me, but it will work for now. Unfortunately, I cannot intersperse the context-sensitive block within the other sidebar (what if I want it in the middle of the other blocks?). Why is $node not in scope for a module?
-Josh-