0

Can I prevent a site from receiving modules installed by a different site in a multi-site instance? In other words, can site A in a multi-site instance not receive a module installed by site B?

  • I am aware that in a multi-site instance, modules that are installed for one site is installed for other sites. For other sites to use said module, it must be enabled in its respective site. In my scenario, I do not want a module to appear at all for a given site, even if it was installed by a different site.
  • I am aware that configuration can take place to install site-specific modules. My question is the reverse: preventing modules for a specific site rather than installing modules for a specific site.
2
  • What do you mean by “receive” in this context?
    – Clive
    Feb 19, 2018 at 19:26
  • "Receive" is having a module available for a respective site. In my case, I do not want to have a module available for a respective site, hence, preventing said site from "receiving" said module.
    – user83312
    Feb 19, 2018 at 19:27

1 Answer 1

1

Yes, the multisite system can do that out of the box. From the Site-specific modules and themes section of the multisite docs:

Each site configuration can have its own site-specific modules and themes in addition to those installed in the standard 'modules' and 'themes' directories. To use site-specific modules or themes, simply create a 'modules' or 'themes' directory within the site configuration directory. For example, if sub.example.com has a custom theme and a custom module that should not be accessible to other sites, the setup would look like this:

sites/sub.example.com/settings.php
sites/sub.example.com/themes/custom_theme
sites/sub.example.com/modules/custom_module

So just make sure you don't put modules that shouldn't be shared in /sites/all/modules; put them in /sites/SITE/modules instead.

Can site A can "block" (for lack of a better term) a module installed by site B, in which site B installs to sites/all/modules?

You could implement hook_system_info_alter in site-exclusive modules to prevent certain ones from ever being displayed to the user on those sites, but as there's no record anywhere of what site downloaded/installed a module to /sites/all/modules, you'd have to keep those modules up to date manually. Unless you supplement that with an API exposed from each site that let each other site know what it had installed and what should/shouldn't be available to install.

Is best practice to configure specific modules per site rather than trying to prevent the transposition?

I think it's fair to say an inclusive rather than exclusive approach is better practice here, any other approach is a bit awkward. It gets more complicated the more automated/robust you want an exclusive approach to be, whereas doing it the other way round just works.

5
  • I am aware of this approach (installing a module for a specific site), but wondered if site A can "block" (for lack of a better term) a module installed by site B, in which site B installs to sites/all/modules. Is best practice to configure specific modules per site rather than trying to prevent the transposition?
    – user83312
    Feb 19, 2018 at 20:18
  • Yes I think it's fair to say an inclusive rather than exclusive approach is better practice here, any other approach is a bit awkward. For example you could implement hook_system_info_alter in site-exclusive modules to prevent certain ones from ever being displayed to the user on those sites, but as there's no record anywhere of what site downloaded/installed a module to /sites/all/modules, you'd have to keep those modules up to date manually. Unless you supplement that with an API exposed from each site that let each other site know what it had installed and what should/shouldn't be...
    – Clive
    Feb 19, 2018 at 20:25
  • ...available to install. Or some variation on that. I guess the point is it gets more complicated the more automated/robust you want an exclusive approach to be, whereas doing it the other way round just works
    – Clive
    Feb 19, 2018 at 20:26
  • I would incorporate your comments into the answer (ie, best practice), and I'll be glad to accept it. I was finding that the site-specific approach is adequate and there really isn't a solid approach for the transposition. Your suggested approach alone comes with guaranteed drawbacks with little to no benefits in which attempting this is wasted effort.
    – user83312
    Feb 19, 2018 at 20:31
  • 1
    Sorry @user257138, your last comment somehow got away from me. Thanks for editing it in
    – Clive
    Mar 6, 2018 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.