5

When running MSM add-on, how can I manage the file upload folders etc, via a config.php file?

Ideally I would want to use a hook to do it, but it doesn't seem to work.

Normally I would do this:

  $config['upload_preferences'] = array(
        1 => array(
            'name'        => 'Images',
            'server_path' => $uploads_path . "/images/",
            'url'         => $uploads_url . "/images/"
        ),
        2 => array(
            'name'        => 'Files',
            'server_path' => $uploads_path . "/files/",
            'url'         => $uploads_url . "/files/"
        ),
        3 => array(
            'name'        => 'Icons',
            'server_path' => $uploads_path . "/icons/",
            'url'         => $uploads_url . "/icons/"
        )
    );

2 Answers 2

6

Actually, every upload location you create is going to have a different ID, be it one site or in multiple sites using MSM. You can thus safely keep everything in config.php becuse every upload location you define (even if you share physical folders) is going to have a different ID anyway.

Basically:

  • Step 1: create all your upload location in the CP for all sites
  • Step 2: take the upload location id and configure all upload location in your central config.php file for all sites. Since they all have specific ids, no conflict problem whatsoever
3
  • I had no idea that was the case Jerome, I guess no harm with either approach. Commented Jan 19, 2013 at 1:45
  • Sure. I just like to have things centralised as much as possible (but that's just me I guess) Commented Jan 21, 2013 at 9:21
  • Good call, this seemed to work. I didn't even think about them having separate ID's I thought they would all start from 1. Thanks!
    – Jason Mayo
    Commented Jan 22, 2013 at 14:22
2

If you want to override MSM settings then you should move this code into the index.php file of the sites respectively.

$assign_to_config['upload_preferences'] = array(
        1 => array(
            'name'        => 'Images',
            'server_path' => $uploads_path . "/images/",
            'url'         => $uploads_url . "/images/"
        ),
        2 => array(
            'name'        => 'Files',
            'server_path' => $uploads_path . "/files/",
            'url'         => $uploads_url . "/files/"
        ),
        3 => array(
            'name'        => 'Icons',
            'server_path' => $uploads_path . "/icons/",
            'url'         => $uploads_url . "/icons/"
        )
    );

Be mindful though, I've experienced a known bug where some values are set in the config of MSM sites but aren't reflected in the CP.

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.