Closed (fixed)
Project:
Advanced User
Version:
master
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
26 Aug 2006 at 07:45 UTC
Updated:
31 Jan 2007 at 17:31 UTC
Jump to comment: Most recent file
I'm getting this errror becuase I think theme.inc hasn't been included yet when the _init hook runs.
See the hook_init documentation, specifically the following:
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).
In the attached patch, I removed the _init hook and moved theme_add_style() into the _menu hook (though it is cached, contrary to the recommendation above), and used the theme() function instead with 'add_style' as a parameter.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | advuser.move_theme_add_style_to_menu.patch_0.txt | 0 bytes | Bèr Kessels |
| #2 | advuser.move_theme_add_style_to_menu.patch.txt | 1.46 KB | Bèr Kessels |
| advuser-move-theme_add_style.patch.txt | 478 bytes | sillygwailo |
Comments
Comment #1
Mojah commentedApplied. Thank you.
Comment #2
Bèr Kessels commentedHere is a patch that moves this into the cahced part of the menu.
Performs much better, is the proper place, and fixes this fatal error.
Comment #3
Bèr Kessels commentedSomehow a previous change/patch slipped in. Rerolled
Comment #4
efolia commented0 byte. Try again ;-)
efolia
Comment #5
hass commentedDon't you realy mean (important - the exclamation mark):
// code which should run exactly once per page view
if (!$may_cache) {
theme_add_style(drupal_get_path('module', 'advuser') .'/advuser.css');
}
Regards
Alex
Comment #6
mcurry commentedPatch that was applied in version 1.5 (8/27/06) may be incorrect, please fix. Changing title to reflect current issue. Please read entire thread, especially http://drupal.org/node/80770#comment-149959
Comment #7
mcurry commentedComment #8
hass commentedthis hasn't been fixed:
Comment #9
mcurry commentedI recategorized this as a task because I thought it was an annoyance, rather than a 'bug'. Does this issue cause a malfunction, or is it merely poorly coded?
Comment #10
mcurry commentedCommited a fix in 1.10. Please wait for the next package build cycle.
Comment #11
hass commentedif you use "$may_cache" the CSS gets added more then once to the page. therefor a bug.
Comment #12
(not verified) commented