If you're making a theme and associated custom modules designed for that theme and no other theme. Is there a way to package the modules with the theme so that when the theme is activated the modules will show up in the module list ready to be activated? The custom modules are build for the theme and so if they can be packaged with the theme that would make it simple to distribute.

I would like to avoid the problems of the user not being able to fully use the theme due to a missing library or module.

If a theme and collection of modules that are packaged in a single zip file, when passed to the drupal installer, permit Drupal the ability to extract the theme and modules to the correct locations? Can it determine the themes dependencies and then install the modules from a url?

Some examples that I can think of is having color pickers for a theme so you can select different colors for the theme in the settings area. I could make custom modules for this and have the modules show up if the theme is active. Maybe also have it alert the user to activate the modules one theme activation. If the theme has a custom slideshow should this be built into the theme or maybe as a packaged module inside the theme that shows up as a module in the modules list to be activated.

Maybe inside the theme package it could have a modules folder that Drupal could then extract the modules and install them into the module directory. On uninstall could prompt the user if they would like to also uninstall the associated modules. If this is possible (or soon to be) this would make managing complex themes clean and simple. It would also keep the module list clean as well. maybe some dependency in the theme info file?

Other thoughts would be if a theme was active maybe it could find said modules and inject rendering options into the modules configurations options.

As of right now this is just a curiosity of mine and I wonder if it could be done. This idea came about after setting up many Drupal sites and making custom modules and themes. Then it hit me what if I could do more with my custom themes by knowing it can only run if all the needed modules where there. Then I wouldn't have to worry about a bad user experience.

  • As far as I know, not really. I sure hope not.
    – Mołot
    Commented Jul 8, 2015 at 15:13
  • is there a better way of packaging themes with custom modules for that theme? Commented Jul 8, 2015 at 15:14
  • Best way, for me, is to make theme test for a module, and use it if it's there. You can zip them together, of course.
    – Mołot
    Commented Jul 8, 2015 at 15:31
  • How are you structuring your zip file. Is the modules in the root with the theme or are they located in a sub directory that Drupal is looking for in the installer? Commented Jul 8, 2015 at 16:02
  • Drupal is not looking for installer, it looks for .info files. I would make common directory for both of them, named after your project, with theme and module subdirectories, named after them respectively. And that's it. For more details - look for another questions, or ask one yourself.
    – Mołot
    Commented Jul 8, 2015 at 18:15

1 Answer 1


Up to Drupal version 7, themes do not allow to have the typical directive for module dependencies in their info files. Because themes are supposed to be module independent.

However, for D8, there is the issue about dependencies[] for themes, so they can depend on modules (created back in 2009 ... current status = needs work).

For D7, Comment #3 in (Drupal core) issue 647014 contains a possible work around that you may want to consider, something like so:

function mytheme_preprocess_page(&$vars)
  if (!module_exists('needed_module'))
    // No needed_module means we need to add it, let everyone know.
    print "<h1>"  . t( 'mytheme requires that module needed_module is installed')
        . "</h1>"
        . "<h6>"  . t( 'warning generated in file: %f', array ( '%f'=>__FILE__ ))
        . "</h6>";
  • what about if you need a color picker for the admin settings. Is that hard coded into the theme or is this a module and have to test to see if the module is installed. Commented Jul 8, 2015 at 15:21

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.