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

tom friedhof - December 11, 2006 - 18:13
Assigned to:Anonymous» tom friedhof
Status:active» reviewed & tested by the community

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.

AttachmentSize
greybox.patch 1.14 KB

#2

Gurpartap Singh - December 12, 2006 - 02:56
Status:reviewed & tested by the community» fixed
AttachmentSize
greybox_fix.patch.txt 1.59 KB

#3

tom friedhof - December 12, 2006 - 23:33

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

Gurpartap Singh - December 16, 2006 - 11:20
Status:fixed» active

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

Gurpartap Singh - December 16, 2006 - 11:21
Version:5.x-1.0» 5.x-1.1

#6

Gurpartap Singh - January 19, 2007 - 20:04
Status:active» fixed

Moved code to hook_menu(). Thanks!

#7

Anonymous - February 2, 2007 - 20:16
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.