Configuring modules in Drupal



You must have heard about where you should put your modules:


• Modules that are downloaded from Drupal.org (or elsewhere) should be stored in sites/all/modules/


• Modules that you have created should go in sites/default/modules/


The fact that this is a common suggestion does not mean it is the only suggested method, or even the best. There are several competing conventions for how you should organize modules.


Each has its advantages and disadvantages.


The sites/all/ directory houses data that is shared among all of your sites. The sites/default/ directory houses data used only for the default site. And the sites/SITENAME/folders contain data specific to the named site.


This all has very practical implications for our sites:


• If a module is stored in sites/all/modules/, then all of our sites will have access to the module


• If a module is stored in sites/books.local/modules/, then only the Books site will have access to that module


• If a module is stored in sites/default/modules/, then no sites will be able to access the module


The same goes for themes and theme/ directories. It should be clear, then, that at least some of the more conventional methods for structuring module directories simply do not apply well to a multi-site configuration.


Another common pattern that works better is to store your custom modules in a subdirectory called custom/. This directory can be stored in sites/all/modules/custom/ or sites/SITENAME/modules/custom/ or both. Likewise, modules from Drupal.org are stored in contrib/ directories. The Vagrant profile automatically creates and utilizes a contrib/ directory for add-on modules.


Sharing modules


The Media module is a popular module for managing media such as images, videos, and audio files. Information about this module can be found at http://drupal.org/project/media. Let\\\'s install this module as a shared module—one that can be used by all of our sites.


The first thing to do is to get the module. You can download it from the URL and then uncompress the file and place its contents in sites/all/modules/contrib/. If you are using the Vagrant profile or have installed Drush (the Drupal Shell), you can run this command from the top level of your Drupal installation


$ drush dl media


Vagrant users should run vagrant ssh to connect to the VM and then run the command from within the VM\\\'s /vagrant/public/drupal/www directory.


Once this command has run, you should be able to find the directory sites/all/


modules/contrib/media/.


Logging in as the administrator on the Books site, we can check for this module in Administration | Modules:


All three of these modules—File entity, Media, and Media Internet Sources—come with the Media module. Let\\\'s enable all three by checking the box and then pressing the Save Configuration button at the bottom of the screen.


Now that those are installed, let\\\'s look at the module administration for Books.


 


Administration | Modules.


Notice that while the same modules are present on the page, these modules have not been installed on the Looks site. So modules are shared in one sense: the same module files are available to every site in our multi-site. But, in another sense, they are not shared. Each site can enable or disable a module, and each site can have different configurations of a module.


 


Unshared modules


Sometimes you would like to have modules available on one site (or a few sites), but not to all. This may be for security reasons, simplicity, or performance. Drupal allows you to accomplish this by storing modules in site configuration directories. Here we will walk though an example.


Let\\\'s say we want to install the Field Text Formatter (textformatter) module, which provides field formatters for text fields and taxonomy term fields. However, we only want this module to be on the Cooks site. To do this, we will store the module in sites/cooks.local/modules/contrib/.


This directory was not created automatically, so we will need to create it now. In a UNIX shell, this is done as follows:


$ cd sites/cooks.local


$ mkdir –p modules/contrib


Now we have our destination. As before, there are two ways we can install the package. We can manually download it from Drupal.org and then uncompress it in the sites/cooks.local/modules/contrib/ directory. Or we can use Drush and have it do the work for us:


$ drush dl \\\\


--destination=sites/cooks.local/modules/contrib \\\\


textformatter


Note that the command has been broken into three lines for the sake of formatting, but normally you will run it on a single line. Most importantly, in order to get Drush to write the module into the Cooks site we need to add the --destination option, specifying the relative path to the cooks. Local modules site.


Now if we log into the Cooks site as an administrator and go to Administration | Modules, we should see the Field Text Formatter module: We can check the Enabled box and press the Save Configuration button as well. Now we have that module installed on cooks.local.


Now let\\\'s look at the Books site. Logging in on that site as the administrator, we can go to Administration | Modules and look for the Field Text Formatter module. But it will not be there. For when we install a module directly into a site\\\'s modules folder, it is not accessible to the other sites. There is no standard way of sharing a module between some but not all sites.


Typically, the safest way to make a module accessible to just some of the sites is to install it once in each site that will use it. This can make maintenance a little more difficult, but it will accomplish the task.

Editor: ankita Added on: 2013-03-13 16:10:05 Total View:335







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---