I am open to doing that with hook_ module code (since i'm doing all my work in a custom module), and I'm open to doing that with Panels, which I'm using. I don't want to add PHP in the admin interface.

Thanks in advance.


Not quite a block, but you can do this with custom panel panes and pass it the $node being viewed. This is the cleanest way. I don't have a link handy for an overview on how to do this, though.

You can also do something similar using a view, and wiring up the relationships / arguments appropriately. You can then stick this view into a panel pane.

The hack is do do something like this in your block code

if (arg(0) == "node" && arg(2) != "edit") {
  $nid = (int) arg(1);
  if ($nid) {
    // do stuff
  • thanks. does the hack fail if the url is "/foo/bar" ??
    – jhchnc
    Sep 22 '11 at 16:58
  • actually, it does not fail. in the name of productivity, we hack. thanks.
    – jhchnc
    Sep 22 '11 at 17:01
  • Glad I could help. The custom panel panes are pretty cool when you have time to look into them.
    – mpdonadio
    Sep 23 '11 at 1:45

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.