0

I have a block that I would like to display on the edit page for a specific content type. Since the content of this block describes the site policy for editing that specific content type, I only want users to see it when editing nodes of that content type.

I tried setting the block display path to node/*/edit* and checking the appropriate content type on the block display menu, but that didn't work.

  • I know it sounds simple, but I though I'd best check - are you setting the block visibility on the correct theme? – Chapabu Nov 28 '12 at 9:24
  • @Chapabu Yes, but a check of the block settings led me to find the answer. – Patrick Kenny Dec 17 '12 at 13:47
1

You could implement hook_block_list_alter() to alter the status of the block. (Replace $bid with the block ID, and $content_type with the content type you are interested to.)

function mymodule_block_list_alter(&$blocks) {
  if (!empty($blocks[$bid]) && ($node = menu_get_object()) && arg(2) == 'edit' && $node->type == $content_type) {
    $blocks[$bid]->status = 1;
  }
}
0

I discovered the source of the problem: the block was set to the wrong language, so I wasn't able to see it even though the path (node/*/edit*) was correct. Setting the block to the correct language allowed me to use the path node/*/edit*.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.