How to render drupal block on particular page in drupal 7 through custom module

If you want to render/display the drupal block on particular page through your custom module just follow the below steps

1. Edit the block and select the Show block on specific pages as “Only the listed pages”  with blank text box under Visibility settings of the block.


2. Implement the hook_block_list_alter(&$blocks) in your custom module

[code type=php]

function lc_assessment_block_list_alter(&$blocks) {
     $node = menu_get_object();
     if($node->field_assessment_type[LANGUAGE_NONE][0][‘value’] == “Regular”) {
             $block = block_load(‘views’, ‘c02ce733ceba5787dd608cf930f282a3’); // block load by module name and delta
      } else if($node->field_assessment_type[LANGUAGE_NONE][0][‘value’] == “Open Book”){
             $block = block_load(‘views’, ’68e1d5d17d89ebdbe87c84d06a84b6ea’);
      if($block->bid) {
                   $block->pages = ‘node/* node/*/submission/*’;
                   $blocks[$block->bid] = $block;