You cannot run install_set_block() to update any blocks when building a profile. In order to assign blocks to regions, etc, you must first run the _block_rehash() core Drupal function, which adds records to {blocks} for all modules (i.e. hook_block()).

FYI when themes are added it seems three blocks get added by default: Navigation, Powered by Drupal and User Login. As a result, upon completion of the installation only three records exist in {blocks} for each theme activated.

Comments

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new593 bytes

The attached patch adds a function called install_init_blocks() which is simply a wrapper around _block_rehash().

James Andres’s picture

I wrote something similar once before. I found that calling _block_rehash() during installation caused the blocks to be setup under the minelli theme. This way annoying because I wanted to to use the theme I had enabled and set as default.

I used this trickery to get around the situation.

function _myprofile_block_rehash($theme_override) {
  global $theme_key, $theme;

  // Save old values
  $old_theme_key = $theme_key;
  $old_theme     = $theme;

  // Call block rehash with overridden data
  $theme_key = $theme = $theme_override;
   _block_rehash();

  // Put the old data back, shhh.
  $theme_key = $old_theme_key;
  $theme     = $old_theme;
}

Useful?

damienmckenna’s picture

That could be useful. I also submitted #399212: install_default_theme() should set the $theme_key global, which is related.

James Andres’s picture

Status: Needs review » Reviewed & tested by the community

Damn, I just got burnt by this problem again.

DamienMcKenna, your original patch is the simplest solution along with the suggestion to update install_default_theme().

+1 for this, works well for me.

James Andres’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.