Skip to main content
10 events
when toggle format what by license comment
Aug 8, 2012 at 13:49 comment added paranod let us continue this discussion in chat
Aug 8, 2012 at 13:49 comment added paranod am i doing something wrong and it doesnt work for me? I have created a module with two files one .module file and one with .info file. It appears correctly in my modules list, i enabled it but the javascript file is still there when i am trying to view page source. :S The only think i have done was to take the function as you told me (the function hook_js_alter) and place it inside the .module file. With no luck!! Do i have to do something else as well?
Aug 8, 2012 at 13:28 comment added Clive Yeah it definitely works in a module (I've just tried it) so that might be the way to go
Aug 8, 2012 at 13:24 comment added paranod yes i have it all to $javascript variable. I cleared the cache and no message appeared. I tried echo to the path as well with no luck:( I dont think my javascript file path is wrong since i have the file inside /sites/all/themes/ninesixty so the path is correct. Maybe a time of thinking for a module?
Aug 8, 2012 at 13:13 comment added Clive $js/$javascript is just the name of the variable to be used in the scope of that function. As long as you're using the same name in the rest of the function (e.g. unset($javascript[$js_path]);) there's absolutely no difference. Remember to clear the caches after adding the new hook or it won't be picked up. If you want to make sure the hook is running, add drupal_set_message('test'); to the function. If you see the message, it's running, and the problem will probably be that Drupal can't find the JS file at the path you're giving it
Aug 8, 2012 at 13:10 comment added paranod Implemented it now as a hook_js_alter(&$javascript) with no luck. I was just wondering if the parameter of the function is correct. Because your code above is using MYMODULE_js_alter(&$js) { instead of hook_js_alter(&$javascript) that drupal suggests (api.drupal.org/api/drupal/modules!system!system.api.php/…. So i guess i will have to implemented it as a module.
Aug 8, 2012 at 12:56 comment added Clive If I remember rightly you should be able to use hook_js_alter() in your theme, but I can't find anything on the docs page that says that you can. Best way would be to try...if not, a custom module it is :)
Aug 8, 2012 at 12:49 comment added paranod Yes thank you! I am calling that code from mytheme_preprocess page in the template.php file. So i will have to create a module to unset the unwanted javascript files in specific path aliases?
Aug 8, 2012 at 12:49 vote accept paranod
Aug 8, 2012 at 12:41 history answered Clive CC BY-SA 3.0