function system_initialize_theme_blocks in Drupal 4
Same name and namespace in other branches
- 5 modules/system/system.module \system_initialize_theme_blocks()
- 6 modules/system/system.module \system_initialize_theme_blocks()
Assign an initial, default set of blocks for a theme.
This function is called the first time a new theme is enabled. The new theme gets a copy of the default theme's blocks, with the difference that if a particular region isn't available in the new theme, the block is assigned to the new theme's default region.
Parameters
$theme: The name of a theme.
2 calls to system_initialize_theme_blocks()
- system_themes_submit in modules/
system.module - system_update_145 in database/
updates.inc
File
- modules/
system.module, line 728 - Configuration system that lets administrators modify the workings of the site.
Code
function system_initialize_theme_blocks($theme) {
// Initialize theme's blocks if none already registered.
if (!db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme))) {
$default_theme = variable_get('theme_default', 'bluemarine');
$regions = system_region_list($theme);
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
while ($block = db_fetch_array($result)) {
// If the region isn't supported by the theme, assign the block to the theme's default region.
if (!array_key_exists($block['region'], $regions)) {
$block['region'] = system_default_region($theme);
}
db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)", $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']);
}
}
}