JS and CSS not loading automatically
JohnNoc-old - December 5, 2006 - 13:32
| Project: | Greybox |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | tom friedhof |
| Status: | closed |
Description
Had a link with the class I configured on the greybox adminpage but nothing is happening...checked the source code of the webpage and the js and css of greybox isn't loading...tried to change to the default class which is greybox but nothing happens still.
tried on a fresh install of Drupal 5.0.beta2...and this is the first contrib module i installed.

#1
The js and css are not getting called on pages that do not contain any nodes. greybox_add_files() is being executed in a hook_nodeapi call, which only gets called when a node is loaded.
I moved the call to hook_menu so it's called on every page regardless if a node is called. I also added $maycache to hook_menu so the menu item for the greybox settings can be cached and not built everytime the page loads.
#2
#3
Hello Gurpartap, I'm not sure the call needs to go in a hook_init hook. According to the API docs (http://api.drupal.org/api/HEAD/function/hook_init) you only want to put code in a hook_init when you want it to execute every time, even for cached pages. I thought it was best to put greybox_add_files() call in the hook_menu hook. Either way works. Let me know if I've misunderstood hook_init, or if this is just a matter of preference. Thanks.
#4
Greetings :) Well I had just preferred to use hook_init() for now, although putting it into hook_menu() would be better as far it counts for performance! Will include this change within next release.
#5
#6
Moved code to hook_menu(). Thanks!
#7