Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way in which from my .module file I can assign a block in a specific region from Dashboard?

share|improve this question
up vote 1 down vote accepted

It can be done in a simple way by mentioning a region key to the $blocks array in the HOOK_block_info(). Follow the code for reference,

     * Implements hook_block_info()
     * @return array
    function my_module_block_info() {
      $blocks = array();
      $blocks['leaderboard'] = array(
        'info' => t('Leaderboard'),
        'status' => 1,
        'region' => 'dashboard_main',
        'weight' => 99,
        'cache' => DRUPAL_CACHE_PER_ROLE,

      return $blocks;
share|improve this answer

In .install file you can add following sql (change the appropriate values)

db_query("INSERT INTO {blocks} VALUES ('gjg', '0', 1, 0, 1, 0, 0, 1, 'my*', '')");
share|improve this answer

yes. see hook_block_info for region

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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