[development] Question on base_path() in hook_init and caching
Doug Green
douggreen at douggreenconsulting.com
Wed Sep 12 06:54:44 UTC 2007
David Metzler wrote:
> I've been recently struggling with getting my cas module to support
> caching (not agressive caching). I started by getting error messages
> when I called arg() in my hook_init and am now having problems with
> base_path() not being defined.
>
> Can anyone suggest a strategy for eliminating these errors? Is there
> a bootstrap function I should be calling in my hook_init?
>
> If not should I be filing a core bug related to this, or should I not
> be able to use arg and base_path in a hook_init function?
>
In Drupal 5.x, I avoid hook_init and actually put all of my
initialization in hook_menu under the !$may_cache else. For example:
function mymodule_menu($may_cache) {
$items = array();
if ($may_cache) {
// initialize menu array...
}
else {
// stuff that you normally would put in hook_init
}
return $items;
}
--
Doug Green
douggreen at douggreenconsulting.com
904-583-3342
Bringing Ideas to Life with Software Artistry and Invention...
More information about the development
mailing list