I'm working on a theme tailored to iPhone viewing using the jQTouch library. This theme would be a base theme for sub-theme development.

Ideally, including the jQTouch library would be handled via the Libraries API module (D6). The jQTouch library requires a higher version of jQuery than is shipped with D6 (1.3.2) and so the jQuery Update module is required as well.

There is at present no way for a theme to declare modules (or libraries for that matter) as dependencies. I suspect this will become more common in the future as theme developers will come to rely on specific JS libraries/jQuery extensions for UI functionality in their themes.

Tim Knittel

Comments

bertboerland’s picture

sorry for noise: subscribing

ohnobinki’s picture

+

jefkin’s picture

I subscribe to the K.I.S.S. principal, so I suggest just telling your users right away.

While by no means a perfect solution, my suggestion here is for anyone who found this entry due to searching for 'theme module dependency' (or the like).

Drupal 8 may incorporate a fancy mechanism for this, Drupal 7 and 6 do not, but in D6 and D7 you can do this, in your template.php in your mytheme_preprocess_page() function add the following:

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>";
  }
  ...
}

Yes, this is a bit kludgy, because it just prints out the error. But if your theme might be broken anyway, best to get the message out. And, if your user installed the theme without the module, they'll know instantly what's wrong. If something breaks, like your user uninstalls the dependency, they'll know right away.

So, you've got all you need to solve it right there. You could get more elaborate, perhaps making your warning include where to download the missing module, but meh.

rickvug’s picture

Status: Active » Closed (duplicate)

Marking this issue a duplicate of #474684: Allow themes to declare dependencies on modules, which has more traction. Completely agree.