0

I'm attempting to render a specific block on a page without rendering the region. I'm assuming the machine name of the block is 23 based on the URL I get when configuring the block.

example.org/admin/structure/block/manage/block/23/configure

I'm attempting to grab the block using the information I've found here

https://www.drupal.org/node/26502

My attempt at it is

$block = module_invoke('block','blockview',23);
print render($block['content']);

But I'm not having any luck.

2
  • 2
    possible duplicate of Printing a block in node.tpl.php
    – Yuseferi
    Commented Aug 27, 2015 at 16:54
  • -1 from me, because themes should never require certain blocks to be available, or modules enabled. Rendering region is the designed way to do it and shortcuts like this may hurt future developers.
    – Mołot
    Commented Aug 27, 2015 at 17:05

1 Answer 1

2

Almost there it's block_view not blockview

$block = module_invoke('user', 'block_view', '2');
print render($block['content']);
3
  • oh wow, I was a lot closer than I realized. Thanks!
    – Amy
    Commented Aug 27, 2015 at 16:49
  • Glad it helped, would you make the question as answered.
    – sam2de
    Commented Aug 27, 2015 at 16:55
  • 1
    Yep sorry, I tried to check it right after you answered but it told me I had to wait a bit.
    – Amy
    Commented Aug 27, 2015 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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