Community Documentation

Directory precedence and multi-site considerations

Last updated October 27, 2009. Created by Matt V. on September 16, 2007.
Edited by LeeHunter, sepeck. Log in to edit this page.

Directory Precedence

Contributed modules and themes can also be placed in the directories /sites/sitename/modules/ and /sites/sitename/themes/. Often, the sitename will be 'default'.

Contributions placed there will only be available to the named site, whereas those under /all/* are available globally. For a single site setup, this probably won't make much difference to you, but if you ever start modifying downloaded code for your own use, it's a good idea to isolate your changes from the clean versions.

It's possible to have two versions of any module (even core ones) available on the site. Your installation will choose from the most specific one available (first /sites/sitename/modules, then /sites/all/modules, then /modules). You can take advantage of this to test patches without damaging your existing files.

Also, you can place modules anywhere within subfolders underneath any of these /modules/ folders. They will be searched recursively when you visit your admin/build/modules page. You can use this to further organise your available items.

Multi-site Considerations

The steps for installing in a multi-site configuration are much the same. The difference is where the modules and themes directory is located. If you use the /sites/all directory, then any module or theme installed under it will be available to all sites using the same code base.

If you wish to limit the access to a module or theme to a specific site, then create a modules and/or themes directory under that sites folder.

sites/example.com.site3/modules
sites/example.com.site3/themes

Anything in a site specific directory will not be accessible to other sites sharing the code base.

Comments

Didn't work for Toolbar Module

I tried doing exactly this to override some styles for the Toolbar core module. I disabled/enabled the toolbar module and cleared the cache, but it did nothing. Does anyone know why this could be?

I tried it again a fourth

I tried it again a fourth time, and it worked. Don't know why it didn't work the first three times.

Install profile modules

What about install profile modules found in profiles/PROFILENAME/modules/ ? Are those seen first, or overridden by sites/SITENAME/module?