0

I'm trying to get a list of all blocks for a certain path but can't figure how to do that.

For example, on the page at url "node/5", I have a few blocks on different regions (sidebars, content bottom, footer). I need to get a list of all these blocks that should be rendered on this page (node/5)

UPDATE:

this seems to work but only for the "content" region.

global $theme;
$all_regions = system_region_list($theme);
$blocks = array();
foreach (array_keys($all_regions) as $region) {
  $blocks += block_list($region);
}

Before this piece of code I run menu_execute_active_handler('node/2', false) because i want to get the blocks for a specific path (Eg: node/2). Unfortunately, it only grab the "content" blocks, no header/footer blocks

Any ideeas? Thanks

1 Answer 1

0

enter link description hereAlready answered before at stackoverflow

  global $theme;
  $all_regions = system_region_list($theme);
  $blocks = array();
  foreach (array_keys($all_regions) as $region) {
    $blocks += block_list($region);
  }

this code will tell about all blocks on current page.

Updated:

check if dpm(_block_load_blocks()); helps you

3
  • this is weird. it only shows blocks from the "content" region. With any other custom region it won't work :((( Oct 1, 2013 at 21:36
  • did you miss to clear the caches after adding the custom regions
    – arpitr
    Oct 1, 2013 at 21:47
  • no, caches are cleared. I just updated the question, maybe you can have a look? thanks Oct 1, 2013 at 21:58

Your Answer

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

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