2

I want to create an install profile that creates the files folder in the document root, www.example.com/files, and not the sites/default folder.

I have tried two methods of doing this and both partially works, they create the folder in the correct place, but when the site is finished installing the admin/config/media/file-system is showing "sites/default/files".

Method 1 used:

Added "$conf['file_public_path'] = "files";" to settings.php

Note: This line was actually removed from settings.php after installation finished

Method 2:

added the below code to [myprofile].profile:

function sitebase_install_tasks_alter(&$tasks, &$install_state) {
  $GLOBALS['conf']['file_public_path'] = 'files';
}

In both cases the Verify requirements step was testing for "files".

How come Drupal all of a sudden seems to lose this setting and instead inserting the wrong value in the db? Do I need to also manually insert this in the db in [myprofile].install?

1 Answer 1

2

You probably want to look at this very recent blog post from PreviousNext: Collecting and writing configuration settings to setting.php from an install profile for answers to this question and your other about creating your own step in an install profile.

From that blog post regarding their install profiles form submit handler:

Then we had to do the actual storing of these variables. Now at this stage the database connection is not setup so you cannot call variable_set(), you have to use another of Drupal's lesser known api functions - drupal_rewrite_settings(). This is the function Drupal uses to write the $databases variable to your settings.php. But with some minor wrangling you can use it to also write $conf variables to settings.php, which are from that point forward available for use via variable_get(). And therefore available for us to use to define our connection settings for the solr server. Because drupal_rewrite_settings should only be called once (to avoid having your settings overridden) we had to duplicate what the standard install does - ie writing the database settings - then we could write our own $conf settings.

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.