Copy of this issue for quick feedback.
--
I am having a trouble developing a module. In my hook_init() function, I call both the function drupal_get_path, and theme_add_style. Whenever I am logged into the admin user account, everything works fine, but when I am anonymous, it comes up with a fatal error because it can't find either function. In drupal 4.6, I can call require_once("includes/common.inc"), but in 4.7, theme_add_style is not found still.

Is there any way to get around having to include common.inc and other files? Is this expected behavior?

Comments

chiggsy’s picture

http://api.drupal.org/api/HEAD/function/hook_init


Only use this hook if your code must run even for cached page views. If you have code which must run once on all non cached pages, use hook_menu(!$may_cache) instead. Thats the usual case. If you implement this hook and see an error like 'Call to undefined function', it is likely that you are depending on the presence of a module which has not been loaded yet. It is not loaded because Drupal is still in bootstrap mode. The usual fix is to move your code to hook_menu(!$may_cache).

bradlis7’s picture

Great, thanks. There should be a handbook page on how to include your own stylesheet.

--
Bradlis7.com | Churchofchristnet