It would be nice if I could configure blocks to display/not to display based upon the taxonomy of the current displayed node.
Hypothetical examples of use:
* Open Source OS Web Page: I could have a block displaying a feed from a site with Linux Kernel news when viewing a node classified under the "Linux Kernel" taxonomy term (node/view/4). The block would also show when viewing all nodes classified under this taxonomy term (taxonomy/page/or/12).
* Regional News / Discussion Site: When viewing any node containing a movie review, a sidebar might display a block with links to local movie theatres. The block would also show when listing all movie reviews (the taxonomy page).
Currently, this functionality can only be accomplished by someone with the "administer blocks" permission adding the path to each node and taxonomy view page in regex form. This means that, for this to work, an administrator must update the block administration page every time a node is added for which we'd like the block displayed. This is tedious for a small site, and impossible for a large one.
How might we go about implementing a better solution?
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedsee taxo powered blocks
Comment #2
TDobes CreditAttribution: TDobes commented"taxo powered blocks" actually do something QUITE different from what I'd like to see. That page seems to discuss creating a block which would display links to all nodes within certain taxonomy terms. While useful, that's not what I'm attempting to accomplish. I'm looking for a further-enhanced ability to specify, as the site admin, when a block does or does not appear. (a supplement to the current regexp system)
I'd like to be able to assign a block to taxonomy term 1, then it would display:
- when viewing the taxonomy term 1 page (taxonomy/page/or/1) or a page with taxonomy term 1 items on it (taxonomy/page/or/1,2,3)
- when viewing a node associated with tid 1 (i.e. node/view/12)
- when the criteria specified by the regexp are satisfied
Hopefully, this clarifies what I was looking for.
Comment #3
herbivorous CreditAttribution: herbivorous commentedYou can write custom blocks that display via
$theme->block($subject, theme_item_list($output));
but which never execute this line if certain criteria aren't met. In which case, no block appears. I discovered this essentially by accident in trying to develop a block that would appear, but some bugs gave me no result for a while. But this might be the sort of tool you're looking for.
Comment #4
jasonmcmunn CreditAttribution: jasonmcmunn commentedI need exactly what Tom needs. I'm hoping someone has told him the info, but I can't figure out how to contact him directly. I need to know how to get the category of the current item, and based on that I can decide to display my block or not. I really need exactly what he asked origionally. Does anyone have an answer?
Thanks!
Comment #5
TDobes CreditAttribution: TDobes commentedjasonmcmunn:
Such a feature does not currently exist in Drupal. (That's why this feature request is still active.) It can be done, but it's not particularly easy.
A hack-ish solution might be to use some custom PHP code in a block. Of course, to determine the taxonomy of a currently-displayed node, you'd have to use node_load, which would add an extra db query and thus increase page generation time. Once killes' node_load caching patch lands, this will no longer be a problem.
But... none of this makes it easier for non-PHP-savvy admins to accomplish this task.
Comment #6
restyler CreditAttribution: restyler commentedMay be my code can help you.
Comment #7
LAsan CreditAttribution: LAsan commentedStill feature request?
Comment #8
thatnewguy CreditAttribution: thatnewguy commentedIn same similar situation myself
Comment #9
thomasmurphy CreditAttribution: thomasmurphy commentedsubscribing
Comment #10
jroth CreditAttribution: jroth commentedsubscribing
Comment #11
docmorphe CreditAttribution: docmorphe commentedsubscribing
Comment #12
emdalton CreditAttribution: emdalton commentedI've been using this code with D5:
I've just upgraded to D6 on a staging server, and now all the blocks are showing everywhere. (I've checked my terms-- they haven't changed.) I'd really like an easier way of doing this, e.g. assigning taxonomy terms to blocks with a pick-list and configuring a setting to do this automatically for all the indicated blocks.
Comment #13
emdalton CreditAttribution: emdalton commentedThanks to eojthebrave, I now have working php code for my blocks in D6: http://drupal.org/node/507540
It would still be nice to be able to pick particular taxonomy terms for blocks and refer to them more easily in the block configuration, e.g. the way one can specify particular pages a block will display on (or not).
Comment #14
sun.core CreditAttribution: sun.core commentedComment #15
dialn CreditAttribution: dialn commentedI also need this function in Drupal 7, not how I tested the module context, blockterm but the block does not appear anyone has gotten in D7
Comment #16
jhedstromThis should be possible with Rules (and directly in core with Views blocks). Anything else to be done?
Comment #30
smustgrave CreditAttribution: smustgrave at Mobomo commentedReading the comments agree with #16
Closing as outdated.
If still a valid request please reopen with an updated issue summary