I'm trying to get a full list of blocks that are active content on the current page. Preferably it would include details of what type of content is displayed in the block.

I need this information to display ads in the blocks. The ads need to be loaded through the javascript snippet, that I can place in the header (through drupal_add_js). But first I need to know if the block that contains the ad is active and that's why I need this list of blocks.

I'm using Drupal 7.

  • do you want to get the id of the block to use it in the js? Commented Jan 23, 2013 at 5:40

2 Answers 2


Follow the instruction to get the details of block for current page

  • In this template_preprocess_page function You can get a variable in that u have all region and it's block array
  • Using the above function we can get all the information of blocks note(if u want to see know the regions list see this function system_region_list

If you want dump out all the blocks on page then do the following:

function THEME_preprocess_block(&$vars) {
   // dsm(); // If Devel module installed.

You do this in your themes template file, replacing THEME (above) with your theme.

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.