1

I am looking for the way to set some settings at the install step.

function genius_profile_final() {
  // Enable default permissions for system roles.
  $filtered_html_permission = filter_permission_name($filtered_html_format);
  user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission));
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'skip comment approval', $filtered_html_permission));

  // Create a default role for site administrators, with all available permissions assigned.
  $admin_role = new stdClass();
  $admin_role->name = 'administrator';
  $admin_role->weight = 2;
  user_role_save($admin_role);
  user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
  // Set this as the administrator role.
  variable_set('user_admin_role', $admin_role->rid);
  // Assign user 1 the "administrator" role.
  db_insert('users_roles')
    ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
    ->execute();

  // Create a role for webmaster
  $webmaster_role = new stdClass();
  $webmaster_role->name = 'webmaster';
  $webmaster_role->weight = 3;
  user_role_save($webmaster_role);
  user_role_grant_permissions($webmaster_role->rid, array_keys(module_invoke_all('permission')));

  variable_set('taxonomy_menu_vocab_menu_rubric', 'menu-genius-navigation-menu');
  variable_set('taxonomy_menu_vocab_parent_rubric', 0);
  menu_rebuild();

  // Set the regional settings First day to Monday
  variable_set('date_first_day', 1);

  // The return message is optional, if you omit it the default will be used.
  return '<p>'. (drupal_set_message() ? t('Please review the messages above before continuing on to <a href="@url">your new Profile Name site</a>.', array('@url' => url(''))) : t('You may now visit <a href="@url">your new Profile Name site</a>.', array('@url' => url('')))) .'</p>';
}

In genius_profile_final(), where as I understood Drupal is fully bootstrapped, I have variable_set('date_first_day', 1), but the first day of the week still is set to Sunday, after the installation. So it is not working as I expected.

I am using the taxonomy_menu module, and I would like to set at the installation step the menu to be linked with the taxonomy. Because I am installing something known, I know the variable names that might be set are:

variable_set('taxonomy_menu_vocab_menu_rubric', 'menu-genius-navigation-menu');
variable_set('taxonomy_menu_vocab_parent_rubric', 0);

This is not working neither.

I have been following https://www.drupal.org/node/1022020 and looking at other examples but I have had no luck to find how to do this.

Is it possible to change settings in an install profile or are there any restriction? In that case, what restrictions are?

What am I doing wrong?

3

I can't find a hook called hook_profile_final on drupal.org. I also can't see where you found it on the link you're using (https://www.drupal.org/node/1022020). You are using an outdated version of the tutorial (https://www.drupal.org/node/67921).

You need to implement hook_install_tasks_alter https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_install_tasks_alter/7 and change a task, or do a form alter of the config page.

  • You are right, I have mixed both tutorials. I will try from the beginning following your suggestion. Thanks. – manou Feb 26 '15 at 15:48
  • OT: Looking to perform the rebuilding permissions after install: drupal.stackexchange.com/questions/149925/… – manou Feb 27 '15 at 12:05
1

Another solution would be to set the variables and other stuff in hook_install() in your profile.install file. I'm doing this in different installation profiles to set admin theme, user roles, date settings and settings for contrib modules.

  • I am doing this also for that kind of settings, but probably because the state of the installation, several variables as those I wanted to set need to be placed into a task. At least I remember that I tried first without task overriding but all settings into the hook_install implementation. Anyway, maybe other people want to try this first than my approved answer. – manou Apr 8 '15 at 20:33
0

The easiest way is to use profile_builder module and endorse the box variable! Reccomended: https://www.drupal.org/project/profiler_builder

  • Hi, thanks for your suggestion. I've installed the profiler_builder module and I've used it to create the profile but unfortunately the result is even worst than my profile from scratch. There is nothing but the theme kept after the profile installation. I am going to play a but more with it, but it seems there is nothing I have to specify a part from check the Variables checkbox. May am I skipping something important on the creation of the profile? – manou Feb 26 '15 at 15:17
  • I am sure the idea is not bad, and I think I was skipping the drush part. Anyway I almost done needed settings by creating the profile by myself and I prefer this option. – manou Feb 27 '15 at 10:17
0

Please make sure that everything gets registered by calling

    drupal_flush_all_caches();

at the end of the profile. This will help having all data that you stored while final step.

Please have look at includes/install.core.inc line number 1561 to 1564 following will help you,

    // Flush all caches to ensure that any full bootstraps during the installer
    // do not leave stale cached data, and that any content types or other items
    // registered by the installation profile are registered correctly.
    drupal_flush_all_caches();
  • Thank you for your comment Rahul, unfortunatelly those variables are still don't set after installation. Any other suggestion? – manou Feb 26 '15 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.