2

I am running expression engine on MSM at the moment. I have got the deployment and ebvironments working properly, my only issues is that there are literally about 30 different file upload paths all together on the whole site. The site environments are:

  • Local
  • Staging
  • Live

The idea would be that I have the upload paths set for the different environments but this is not working at all on the config_bootstrap.php file in this area:

if ('local' === NSM_ENV) { 

    // Environment DB configuration
    $env_db_config = array(
        'hostname' => 'localhost',
        'username' => 'root',
        'password' => 'root',
        'database' => 'ngrto-stage2',
    );


    // Environment global vars
    // These will be available in youre templates
    // 'global:' is not required, it's just a naming convention we use @Newism
    // Example: 'global:cm_subscriber_list_slug' will be available in templates as {global:cm_subscriber_list_slug}
    // Overrides anything in $default_global_vars
    $env_global_vars = array(
        'global:cm_subscriber_list_slug' => ''
    );

    // Environment config variables
    // Overrides anything in $env_config
    $env_config = array(

        'upload_preferences' => array(
            1 => array(                                                            // ID of upload destination
                'name'        => 'Staging Image Uploads',                          // Display name in control panel
                'server_path' => '/home/user/example.com/staging/images/uploads/', // Server path to upload directory
                'url'         => 'http://staging.example.com/images/uploads/'      // URL of upload directory
            )
        )
    );


}

Can anyone think why this would not work and a better solution to it?

Thanks,

3
  • Are you wanting to make these paths without adding them into the DB? I’m afraid that’s not possible, if so. You’ll need to create the DB entries for the file paths first before you can start adjusting them in your master config. Commented Jan 12, 2014 at 22:47
  • Yeah I have looked at adding the correct id for the paths already set out as they are in the db. I may play around with it to see what works. Thanks
    – M dunbavan
    Commented Jan 13, 2014 at 7:56
  • You have to create them in the CP before they will show up. Usually I just add them all into the config file first, then just quickly add them all in the CP.. just enter a name, and once you submit it, it'll update with the info from the config file. Commented Feb 6, 2014 at 13:39

1 Answer 1

2

I use the Focus Labs 'master.config' system rather than the Bootstrap one but it's basically just a variation on the same theme AFAIK so hopefully this input will still be applicable. What I've found is that whilst, in theory, you're supposed to create the upload destinations before you can redefine them with your config file, in practice it is possible to define the destinations in the config first and then create them in the CP.

If I define an upload destination in my master.config file and then go to the CP and look at the File Upload destinations, it is not visible. But as soon as I create a new upload destination via the File Upload Preferences, I find that I am able to type any old random gibberish for the name, path, URL etc (i.e. any of the parameters that your config specifies) and once I hit 'Submit' to create the destination directory I find that the system will have picked up on the info from the config file and created the destination with those parameters, not the gibberish that I typed.

Assuming that you are starting with no Upload Destinations, the CP, as it creates then, assigns them array numbers, and if config data exists for that array number then it will apply it. So if I define three destinations in the config with array numbers of 1, 2 and 3, then I create three upload destinations in the CP, the first destination will use the parameters that I predefined for #1, the second will use the parameters for #2, etc.

It gets bit more complicated if you have created a destination but then deleted it, because I think the system still considers that array number as 'used', so a newly created destination (via the CP) might not be assigned the array number that you were expecting. But adjusting the array numbers assigned to the destination in the config can solve that.

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.