How to link external Javascript files?

Author Message

Gerhard Hoogterp

Tuesday 18 February 2003 3:34:56 am

While converting a site to ez3 I found a number of gotcha's for external files. Basicly css and js files.

The CSS can be handled by

<link href={"stylesheets/general.css"|ezdesign} rel="stylesheet" type="text/css" />

where the stylesheets directory is under design/slo/ (in this case) No problem there. background images in the CSS style can be found using relative paths (../images) which solves most of my problems there.

Javascript files are more problematic.

Mozilla reports:

Error: syntax error
Source File: http://ezslo.slo.nl/design/slo/javascript/screen.js
Line: 2
Source Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

The path is ok, that's where the file is. Of course it doesn't contain a DOCTYPE line so where thatone comes from is beond me.

The call is made through:

<script language="JavaScript" src={"javascript/screen.js"|ezdesign} type="text/javascript">
</script>

which works as it should outside of ez.

Who can shine some light here? Thanks.

Tony Wood

Tuesday 18 February 2003 4:42:39 am

> While converting a site to ez3 I found a number of gotcha's
> for external files. Basicly css and js files.
>
> The CSS can be handled by
>
> <link href={&#034;stylesheets/general.css&#034;|ezdesign}
> rel="stylesheet" type="text/css" />
>
> where the stylesheets directory is under design/slo/ (in
> this case) No problem there. background images in the CSS
> style can be found using relative paths (../images) which
> solves most of my problems there.
>
> Javascript files are more problematic.
>
> Mozilla reports:
>
> Error: syntax error
> Source File:
> http://ezslo.slo.nl/design/slo/javascript/screen.js
> Line: 2
> Source Code:
> <!DOCTYPE html PUBLIC &#034;-//W3C//DTD XHTML 1.0
> Transitional//EN"
>
> The path is ok, that's where the file is. Of course it
> doesn't contain a DOCTYPE line so where thatone comes from
> is beond me.
>
> The call is made through:
>
> <script language=&#034;JavaScript&#034;
> src={&#034;javascript/screen.js&#034;|ezdesign}
> type=&#034;text/javascript&#034;>
> </script>
>
> which works as it should outside of ez.
>
> Who can shine some light here? Thanks.

Try adding |js to your http conf insert for the site. By default .js files are not allowed. If you add them they then work.

i.e. change
RewriteRule !\.(gif|css|jpg|png)$
to
RewriteRule !\.(gif|css|jpg|png||js)$

While your there probably best to add |ico for .ico files so you can get your favicon working :)

Tony

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Gerhard Hoogterp

Tuesday 18 February 2003 4:55:23 am

> i.e. change
> RewriteRule !\.(gif|css|jpg|png)$
> to
> RewriteRule !\.(gif|css|jpg|png||js)$
>
> While your there probably best to add |ico for .ico files so
> you can get your favicon working :)

And gif as there's still a lot of it around.. Thanks, completely forgot about those setting.

Kristoffer Karlsson

Wednesday 16 November 2005 4:00:02 am

In which file am I supposed to change this?

> RewriteRule !\.(gif|css|jpg|png)$
> to
> RewriteRule !\.(gif|css|jpg|png||js)$

_____________________________________
Blog: http://www.kristofferkarlsson.com
Website: http://www.spelkanalen.com

Mark Marsiglio

Wednesday 16 November 2005 5:21:22 am

This is either in an .htaccess file in your root directory (enable viewing of files that begin with a period in your FTP client), or your httpd.conf. Unless you own the server and have root access, the .htaccess is the most likely file to change.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

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

eZ debug

Timing: Jan 18 2025 11:41:44
Script start
Timing: Jan 18 2025 11:41:44
Module start 'layout'
Timing: Jan 18 2025 11:41:44
Module start 'content'
Timing: Jan 18 2025 11:41:44
Module end 'content'
Timing: Jan 18 2025 11:41:44
Script end

Main resources:

Total runtime0.0165 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.4844152.6406
Module start 'layout' 0.00670.0030 742.125039.4922
Module start 'content' 0.00970.0047 781.617297.3672
Module end 'content' 0.01440.0021 878.984438.3047
Script end 0.0165  917.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002615.9866140.0002
Check MTime0.00116.8718140.0001
Mysql Total
Database connection0.00074.246510.0007
Mysqli_queries0.003018.119930.0010
Looping result0.00000.090910.0000
Template Total0.001710.310.0017
Template load0.00106.201010.0010
Template processing0.00074.028710.0007
Override
Cache load0.00063.443110.0006
General
dbfile0.00021.469880.0000
String conversion0.00000.060640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs