0

It just discovered that my script.js in my theme is ignored for anonymous users. But only on certain pages. When logged in everything works on all pages. When logged out things only work in some content nodes. For example I have a navigation menu outside of the system menu. It's an exposed block from a view, that I use as a navigation menu to mirror the taxonomy (the taxonomy module does not work for me). I use the theme's script.js to collaps and expand menu items as appropriate. But this is ignored when logged out on most pages (but as I said it works when visiting some content nodes). What is this?

I also discovered that flexslider doesn't wok when logged out. But it works in content nodes... I must be missing something.

I have tried adding:

drupal_add_library('system', 'jquery', 'ui.sortable', 'ui', 'drupal.collapse');

... in my template.php (in template_process_page, and I also tried to add it in template_preprocess_html). In the Firebug "Net" tab I can see that my script,js is loaded together with jquery and a whole bunch of js files. So if everything is loaded, why is it ignored on certain pages when logged out? Any ideas?

Edited... I also have tried to add break points in my script.js file and it is clear that the script is ignored all together on certain pages.

6
  • Have you checked if those where loaded from somewhere else?
    – GwenM
    Jan 19, 2016 at 13:57
  • have you tried that way? drupal_add_library('system', 'jquery'); drupal_add_library('system', 'ui.sortable'); ...
    – GwenM
    Jan 19, 2016 at 14:01
  • You mean the librarires... not sure how to check from where they are loaded though.. I try to figure it out in Firebug...
    – TBJ
    Jan 19, 2016 at 14:03
  • No, I haven't tried that... I will do that right away.
    – TBJ
    Jan 19, 2016 at 14:04
  • No that did not work. Since the files are actually loaded, I can't understand why they are ignored... I keep digging.
    – TBJ
    Jan 19, 2016 at 14:11

1 Answer 1

0

Worked it out! I post an answer myself in case anyone else has the same issue. Hopes it helps somebody.

I had to add the jquery.cookie library in my template.php

drupal_add_library('system','jquery.cookie');

And it seems you were right to add only one library at a time, Namari, it didn't work until I tried that. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.