blocks

Programmatically Set Node Type Visibility for Blocks

If you've ever created a block with hook_block_info you know that the visibility options are limited to just pages. In my case, I wanted to set my block to only appear on certain node types. The challenge is that you can't do it from hook_block_info because node type visibility isn't dictated by the block module, it's provided by the node module.

But fear not, there is a way! If you want to add content type based visibility for your block, you can do so in the .install file of your module using hook_install.

Display Blocks Based on Node Taxonomy in Drupal without Coding

I needed to display a block based on a few conditions: Display on the node page for a particular content type. Only show up if that node had a particular taxonomy term assigned. Drupal let's you control the visibility settings for blocks, but the options are limited to Pages, Content types, Roles, and Users. Content types would allow me to let the block appear for my content type, but not based on it's taxonomy terms.
Subscribe to RSS - blocks