I've starting creating my first Installation profile and saw there wasn't theme functions in CRUD, so I've coded some:

/* --- THEME FUNCTIONS --- */

/**
 * Enable theme
 */
function install_enable_theme($theme) {
  system_theme_data();
  db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $theme);
}

/**
 * Disable theme
 */
function install_disable_theme($theme) {
  system_theme_data();
  db_query("UPDATE {system} SET status = 0 WHERE type = 'theme' and name ='%s'", $theme);
}

/**
 * Set default theme
 */
function install_default_theme($theme) {
  install_enable_theme($theme);
  variable_set('theme_default', $theme);
}

Usage of these in the .profile file would be like this:

// Set site theme
  install_disable_theme("garland");
  install_default_theme("mytheme");

One thing I noticed and wasn't sure how to solve was when using the above functions in an installation profile, the default navigation block isn't shown (not enabled); any thoughts on this?

Comments

boris mann’s picture

Assigned: Unassigned » boris mann

Great ideas. I've got some updates to make, so I'll add these in the next day or so.

I'm not sure what you're seeing with the default Navigation block. "works for me". Maybe open a separate issue and/or provide some more details. I do extensive modifications to the menu system in my install profile, and it all works.

eferraiuolo’s picture

The issue seems to be what the block.module setup is by default when it's installed. Since in 5.x blocks are now related or subordinate to themes, the Garland theme receives the navigation block by default, but when using my theming functions to enable and set a theme as the default, entries are being made into the blocks database table to enable the blocks for the newly enabled theme.

When I find a solution I'll post info and code for it.

eferraiuolo’s picture

I've found a solution and modified my Enable theme function to this:

/**
 * Enable theme
 */
function install_enable_theme($theme) {
  system_theme_data();
  db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $theme);
  system_initialize_theme_blocks($theme);
}

adding the call to the system_initialize_theme_blocks function solved the issue I was having, now when you call enable theme, it give the theme the default set of blocks.

boris mann’s picture

Status: Active » Fixed

Thanks for the followup. Latest HEAD has this committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)