Monday, October 29, 2012

Setting a different default theme by default in an install profile

For an install profile you can look at the profiles that are included in the drupal install.
They can be found in sitename/profiles
As in an standard Drupal 7 instal there are 2 profiles 'minimal' and 'standard'.

The profiles are somewhat like modules and also work like that.

The profilname.info file can be used to define dependencies and thus enabling the defined modules when this profile is chosen.
again look at the standard.info file for an example.

In the .profile file you can alter the form that is used upon install and predefine values for fields.

but to set an other default theme you need the .install file.

In the .install file you place an hook_install()

at the end of your profilename_install() hook you place the following code:
profilename_install() {
// some other code

  db_update('system')
    ->fields(array('status' => 1))
    ->condition('type', 'theme')
    ->condition('name', 'yourthemename')
    ->execute();
  variable_set('theme_default', 'yourthemename');
}
Just make sure that yourthemename is available in your install directory.


Setting the theme settings.

The next step is setting the theme variables but I haven't figured that out so I will update this post when I get there...

I think you can set the values in the 'system' table WHERE `name` = 'themename'
Best way to do this is click the theme to the point you like it, then go to the database and copy the values of the according `info` field.