3

I'm creating an install profile and I just can't seem to get my blocks enabled.

When I check the database after using the code below in my install function it puts the records in the block table, but the status is set to 0 and the region detail isn't inserted.

I'm using code from other install profiles and I can't see why mine isn't working - works fine on things like the erecruiter profile, the omega profile, but whenever I try it never works! Anyone experienced similar?

// Enable some standard blocks.
$default_theme = 'mytheme';
$admin_theme = 'seven';
$values = array(
array(
  'module' => 'system',
  'delta' => 'main',
  'theme' => $default_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'content',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'node',
  'delta' => 'recent',
  'theme' => $admin_theme,
  'status' => 1,
  'weight' => 10,
  'region' => 'dashboard_main',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'user',
  'delta' => 'login',
  'theme' => $default_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'sidebar_first',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'system',
  'delta' => 'navigation',
  'theme' => $default_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'sidebar_first',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'system',
  'delta' => 'powered-by',
  'theme' => $default_theme,
  'status' => 1,
  'weight' => 10,
  'region' => 'footer',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'system',
  'delta' => 'help',
  'theme' => $default_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'help',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'system',
  'delta' => 'main',
  'theme' => $admin_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'content',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'system',
  'delta' => 'help',
  'theme' => $admin_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'help',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'user',
  'delta' => 'login',
  'theme' => $admin_theme,
  'status' => 1,
  'weight' => 10,
  'region' => 'content',
  'pages' => '',
  'cache' => -1,
),
array(
  'module' => 'user',
  'delta' => 'new',
  'theme' => $admin_theme,
  'status' => 1,
  'weight' => 0,
  'region' => 'dashboard_sidebar',
  'pages' => '',
  'cache' => -1,
 ),
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
  $query->values($record);
}
$query->execute();
1
  • 1
    You code looks to be correct, from what I can tell, which leads me to be that there is some other factor. Is your mytheme theme getting set as the default theme and enabled correctly? Commented Aug 24, 2012 at 20:46

1 Answer 1

3

Are you using the Profiler library to drive your installation profile? If so, there's a "feature" in the 7.x-2.0-beta1 release that causes this behavior. In short, there's some legacy code that disables all blocks in the database upon installation.

If you're using the Profiler module, upgrade to the latest development snapshot to get the fix.

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.