Function path_to_theme() can catch you

Return the path to the current themed element.
The main thing is that if you will call it from the module preprocess hook - it will return the
path to the module.

So if you want to keep your logic in code and still be able to help your designer/js-coder (who doesn't know for sure where is the custom module files, but know the theming a bit):

drupal_add_js(drupal_get_path('theme', variable_get('theme_default', 'garland')) ."/js/cooljavacriptfilehere.js");

From api.drupal.org:
It can point to the active theme or the module handling a themed implementation. For example, when invoked within the scope of a theming call it will depend on where the theming function is handled. If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the active theme. When called outside the scope of a theming call, it will always point to the active theme.

No comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.