2

I recently started working on an existing D7 site, which has its own custom theme. With this theme only, some CSS and JS files are not loaded at all for anonymous users. Logged in users dont have that problem. When I switch the theme to Garland for example, the CSS and JS files are loaded correctly for anonymous users.

The CSS or JS files are either coming from core, or from some contrib modules.

Where should I start looking?

1
  • Thank you for the answers. In the end I found the issue. The theme was dependent on another base theme which was also custom. Inside that theme, there was a php file which was checking if the user was logged in. Else, it was stripping all the js. Removing that code solved my problem. Feb 15, 2013 at 15:39

3 Answers 3

2

First of all you should find where the CSS or JS is being added, this being Drupal, there are tons of ways that this could happen.

if they're added using drupal_add_js and drupal_add_css (which they should be) you have to make sure that possible template differences beetween roles and permissions both print out the $styles and $scripts variables.

If the theme follows D7 standards there should be an html.tpl.php file somewhere (most likely the root) in the theme, that would be the best place to start looking. If that does not exist, try page.tpl.php.

Post your findings and it'll be easier for us to help you.

1
  • echo $styles; echo $scripts; These lines are included in my html.tpl.php file. And there is no condition on them for roles, permissions or anything else. Feb 11, 2013 at 13:40
0

You might also want to make sure the old developer wasn't doing something funky in the template.php file (if there is one, it will be located in your custom themes directory).

2
  • The old developers went crazy on the the template.php file actually :) I dont know which variables or arrays can affect the script or style output. Feb 11, 2013 at 13:43
  • Obviously if this site is live you wouldn't want to do this but if you can make a backup to work on I would rename the template.php to templateOLD.php, clear the caches and see if the CSS and JS files load. If it does that means your problem lies within that file and it's just a matter of finding it.
    – Brian
    Feb 11, 2013 at 14:16
0

This sounds like a caching issue. Clearing caches from drush does not always clear CSS caches because of permissions. Try clearing caches from the GUI and/or testing it without caching for anonymous users.

1
  • I also thought that at first, but clearing the caches, or disabling the caches altogether doesnt help Also default themes work ok, so I dont think it is a caching issue. Feb 11, 2013 at 13:37

Your Answer

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

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