Javascript problems

Author Message

Tore Åbodsvik

Wednesday 05 November 2003 4:29:09 pm

Hi.

Im having problem getting a javascript running.
I have tried a variety of solutions.
But non of them worked for me.

The latest i tried to do was to access the .js file directly through:
/design/plain/javascripts/xxxx.js

I can't seem to reach the .js file. I only get the main tpl file loaded.

This is my .htaccess file:

<FilesMatch ".">
order allow,deny
deny from all
</FilesMatch>

<FilesMatch "(index\.php|\.(gif|jpe?g|png|css|js|html))$">
order allow,deny
allow from all
</FilesMatch>

RewriteEngine On
RewriteRule !\.(gif|jpe?g|png|css|js|html)$ index.php

DirectoryIndex index.php

As i understand this is correct, in mind of getting the js file to be reachable?

Regards
Tore

Tom Couwberghs

Wednesday 05 November 2003 11:58:02 pm

Hi Tore,

First of all, your server config looks good to me.

As you'll know eZP makes use of { and } as syntax for its template operators. So if you write javascript-code directly in your templates it won't work because eZP will try to parse it with it's template engine.

There are a couple of ways to get around this:

You could replace all your javascript { and } with respectively {ldelim} and {rdelim}, as this will produce the wanted character. But it will make your javascript code a mess.

Another way to do this is writing a .js file with the javascript code in it and writing a tag like

<script language="JavaScript" src="path/to/your/file.js">
</script>

So the general idea is: use js-files to put as much code in as you can, and if you need to embed js-code in your template use the {ldelim} and {rdelim} statements.

HTH

Tom

Tore Åbodsvik

Thursday 06 November 2003 12:25:34 am

The javascript code which i am using is placed inside a .js file.
Which i have placed inside /javascripts folder under the plain folder.
Eg. /design/plain/javascript/

I have in the template used this way for trying to reach the .js file:
<SCRIPT SRC={"javascripts/script.js"|ezdesign} TYPE="text/javascript" LANGUAGE="JavaScript"/>

This does not work.

I have tried typing the full pathto the .js file. Which does not work.

I then tried to reach the .js file directly through the browser.
as typing:
http://scamp.tasy.no/design/plain/javascripts/gfs_construct.js

This will give me a kernel 20 error. And the site will show me the main pagelayout file.

What am i doing wrong here?

Regards.
Tore

Tom Couwberghs

Thursday 06 November 2003 12:45:40 am

Hi Tore,

I've tried to simulate what you are doing, and I can access the .js file without problems so maybe it is your configuration after all. I've included mine, maybe this can help.

Greets,

Tom

<VirtualHost *:80>

<Directory "c:/wwwsrv/ezp323">
Options FollowSymLinks Indexes ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>

RewriteEngine On
RewriteRule !\.(gif|css|jpg|png|js|mpg|avi|swf|xsl)$ "c:/wwwsrv/ezp323/index.php"

Serveradmin tcouwber@sckcen.be
DocumentRoot c:/wwwsrv/ezp323
Servername ezp323.tclocal.homeip.net
ErrorLog logs/ezp323.tclocal.homeip.net-error_log
CustomLog logs/ezp323.tclocal.homeip.net-access_log common
</VirtualHost>

http://ezp323.tclocal.homeip.net/design/standard/js/test.js

Tore Åbodsvik

Thursday 06 November 2003 3:31:32 am

No, it will not work. :(

I started up the debugger.
And this is what it says when accessing the http://*site*/design/plain/javascripts/file.js
(errors)

1.eZ debug

Error: index
Nov 06 2003 12:23:22

Undefined module: plain

Is this a clue to the puzzle?

Regards.
Tore

Tore Åbodsvik

Thursday 06 November 2003 4:46:50 pm

Update:

I have removed the .htaccess file altogether.
And still nothing works. Can't access any .js files.

But i still get the kernel 20 error. And when debugoutput is on i get:
Error: index
Undefined module: plain (Or whicevere folder that is standing after /design/.

I can't seem to get through this one.
Any one else experienced this problem?

Regrds
Tore

Paul Forsyth

Friday 07 November 2003 1:36:57 am

Are your file permissions correct?

I've went to the link you gave and i see lots of template errors like:

eZTemplate: Loading template "user/login.tpl" with resource "design"

eZTemplate: Loading template "pagelayout.tpl" with resource "design"

Notice: Nov 07 2003 10:31:01

eZTemplate: Loading template "page_head.tpl" with resource "design"

Notice: Nov 07 2003 10:31:01

eZTemplate: Loading template "link.tpl" with resource "design"

eZ will complain if it cant access the templates it needs. I believe this is independant of the server config file...

Look at this site: www.planet-troy.com for a javascript example. In the source at the top you will see what we have done, and its what you expect:

http://www.planet-troy.com/design/user/templates/javascript/troy.js

will bring up the js file.

paul

Tore Åbodsvik

Friday 07 November 2003 3:43:21 am

I have changed the file permissions. chmod
The templates are now loaded i belive in a correct way.

But when i try to access the .js file and get it up the way you had in your link i get the front template and the following error:

Error: index
Nov 07 2003 12:37:49

Undefined module: plain

This is the Url for trying to reach the .js file with a full path.
http://scamp.tasy.no/design/plain/javascripts/gfs_construct.js

Is there anything else in the system that controlls access to a .js file other than .htaccess?
A file under the settings folder?

I am very greatfull for all the help i can get.

Regards.
Tore

Paul Forsyth

Friday 07 November 2003 6:13:30 am

Concentrate on fixing your other template issues.

http://scamp.tasy.no/

produces lots of errors. I tried this link:

http://scamp.tasy.no/content/view/full/44

and i see that the view module isn't present either.

It does look like a permissions issue.

paul

Tore Åbodsvik

Friday 07 November 2003 7:39:43 am

When you talk about permissions.
Are you talking of file permissions in the file system like chmod 777, or are you talking about permissions inside the ez system?
for the anonymous user?

Regards
Tore

Paul Forsyth

Friday 07 November 2003 8:09:38 am

I meant file permissions.

Ooops, i didn't look close enough at the warnings on the screen. Most of them are notices which are not errors. Sorry for that.

Still, im puzzled why links like:

http://scamp.tasy.no/content/view/full/44

produce a module not found message. Have a look at this link since there are a few other messages in there which might help you debug this. Try replacing the 44 with a real node id found from your admin.

I've a feeling that resolving this will also solve the javascript problem.

paul

Tore Åbodsvik

Saturday 08 November 2003 10:45:14 am

Hi again.
Im soon going to climb the walls....

I have done all work over again.

Wiped all files off design and settings directory (thank god for backups)....

Set up the new site from ground up. (As i am on hosting there is some limitations).

Created new /Settings/siteaccess/[site]
Created new /Settings/siteaccess/[site_admin]

Created the new /design/[site]/* directories.

Inserted the new pages, and got it all to work.
Except the .js files.

all the .js files and all dir's is chmod 777.
The anonymous user have unrestricted access.

The .htaccess file was checked tenfold times and it is the way it should be.

BUT: now i have tried to do it the other way araound. and have trying to set restrictions on all files except .js files.

This i have tried to do with the .htaccess file.
But nothing i do seem to have any effect.

I still can access the .gif .jpeg files. Even when i have "banned" the in the .htaccess file.

Have tried to set the path to the index.php file and playing araound with almost all the settings. Nothing have any effect on my site.

[.htaccess file]

<FilesMatch ".">
order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index\.php|\.(js))$">
order allow,deny
allow from all
</FilesMatch>
RewriteEngine On
RewriteRule !\.(js)$ index.php
DirectoryIndex index.php

[/.htaccess file]

Regard Tore

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.