Are you enjoying the extensions? Did you like the support? Help others decide.

Leave a review
27Mar2023
Information
Print

Troubleshoot missing styles and scripts (access permissions errors)

Information
First published October 13, 2015
11082 hits - No rating
 
For:
Any Simplify Your Web extension that has an output display

After installing any of the Simplify Your Web extensions (or after moving the site to a different server with different settings), some users may experience issues with the extension's HTML output. No matter the setup, the output does not look anything like any of the demos or screenshots that the user has seen...

Feelings of disappointment occur (it should work from the start, right?). What is really happening?

This tutorial will help you diagnose the issue (or confirm it) and guide you to help you fix it.

Joomla 4 The cached stylesheets and scripts are no longer located in the /cache folder, but in the /media/cache folder. Change the following instructions appropriately.

Step 1 Open the page source view

Most browsers have the option to show the source code generated by web pages. For some, just a right-click on the page is all it takes to find that option.

View source

Step 2 Locate the stylesheets and/or scripts associated with the extension you are trying to troubleshoot

Generated stylesheets and scripts are located in the /cache folder of the Joomla implementation.

For instance, for the Trombinoscope Contact module, you could find something like:

<link rel="stylesheet" href="/cache/mod_trombinoscopecontacts/style_92.css" type="text/css" />

Step 3 Check the file(s) content

In page source view, most referenced files can be clicked on. Click on the found link(s) and check its(their) content.
If anything goes well, CSS or javascript code must be visible, although condensed.

For instance, the style_92.css file from the previous example should contain something like:

.te_92 {overflow: hidden;position: relative;width: 100%;}.te_92 .personlist {overflow: hidden;text-align: center;font-size: 0; }.te_92 .groupheader {display: inline-block;width: 100%;font-size: 14px;text-align: left;}.te_92 .groupheader .header {border-bottom: 1px solid #DDDDDD;}...

If indeed there is a problem, there should be no code inside that file, or just a few lines (most likely your own additions).

Step 4 Check the error logs

Since v1.2.5, the extensions library lib_syw logs errors. Go to the logs folder specified in the Joomla configuration of your site and look for the file syw.errors.php. The errors will be clearly notified in that file, if any. This will ensure you are indeed looking at a problem that comes from file access permissions.

The file content may be:

Forbidden
You don't have permission to access /cache/mod_trombinoscopecontacts/style_92.css on this server.

Simplify Your Web extensions build stylesheets and scripts 'on the fly' to reflect any change(s) you make in the extension's settings. The main benefit is that you get the minimum amount of necessary code, therefore reducing page load times.

Step 5 Modify the .htaccess file

If the problems are directly linked to file permissions, ensuring those permissions are 644 or 744 (added owner 'execute') may not be enough. You need to tell the server what files can have direct access. And it has to be done in the .htaccess file.

Step 5a Using Admin Tools

When using 'Admin Tools Professional' for instance, the modifications are easy. Go to the 'Exceptions' section of the htaccess maker tool and add the faulty files to the 'Allow direct access to these files' section.

For instance, for the Trombinoscope Contacts extension, add:

cache/mod_trombinoscopecontacts/style_92.css

You can also just white-list the /cache/mod_trombinoscopecontacts folder.

Step 5b Manually

First, make a copy of the original .htaccess file. Then add the following lines to the file (this is for Trombinoscope Contacts):

##### Advanced server protection rules exceptions -- BEGIN 
RewriteRule ^cache\/mod_trombinoscopecontacts\/style_92\.css$ - [L]
##### Advanced server protection rules exceptions -- END

You may also just allow all files from sub-folders in the /cache directory (the following code allows all files but excludes php files from access authorization for the Trombinoscope Contacts module):

##### Advanced server protection rules exceptions -- BEGIN 
RewriteCond %{REQUEST_FILENAME} !(\.php)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^cache\/mod_trombinoscopecontacts/ - [L]
##### Advanced server protection rules exceptions -- END

Do not give access permissions to the whole /cache folder. It is safer to target specific sub-folders or files of extensions you trust.

IIS servers

The previous settings will work on all Apache servers. When using IIS servers, matters get a little bit more complicated because they require the use of server tools to apply the proper file permissions. For help on rewriting rules from Apache to IIS, you can refer to this article for help.