Include Javascript from outside Template / Override Folder

Author Message

Michael Fürst

Wednesday 15 April 2009 12:41:44 pm

Hi There,

I need to include a .js File from a directory outside the template / override directory.
<b>Templates are here</b>: /design/mydesign/templates
<b>JS is here</b>: /design/mydesign/javascript/ineedthisJS.js

Inclusion like this doesn't work:

<script type="text/javascript" src="{"javascript/newsticker/jquery.newsticker.js"|ezdesign(no)}"></script>

cause in the JS there are some different <script> sections defined again - i cannot change the JS, cause it's generated dynamically by our adserver (would be horrible on updates).

So i want to include the js. file with the {include} function. But i can only find includes of files in the template directories, for example:

{include uri="design:link.tpl"}

Does anyone know wich URI parameter beside "design" i can use, so that i can point to the .js File in the "javascript" directory?

Thanks in advance,
Regards,
Michael

Noicokuna Niemoge

Thursday 16 April 2009 3:38:19 am

Why an inclusion of script type="text/javascript" doesn't work if, judging from the file name, it's a jquery fuction/plugin?

Maybe check if the file is correctly loaded? Is the path OK? Test the hard-coded path to be sure.

Also, because of rewrite engine switched on (and because I can't find any better solution), I tend to include js files from folders outside eZ structure. Or, in eZ root directory, create any category, put there js files and put a htaccess in it like this:

RewriteEngine Off
DirectoryIndex index.html

<FilesMatch "\.(js)$">
order allow,deny
allow from all
</FilesMatch>

I know it's not elegant, but as I asked in these forums for a good way to include js files and external php scripts, nobody answered... (and I both don't have time and are not good enough to make eZ extensions for trivial little scripts)

Shiki soku ze ku...

Yannick Komotir

Thursday 16 April 2009 3:50:22 am

Hi you can generate your js in /design/mydesign/templates/ like a .tpl and include this like you talk

{include uri="design:link.tpl"}

--
Sorry for my poor english^^

<|- Software Engineer @ eZ Publish developpers -|>
@ http://twitter.com/yannixk

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 18:16:44
Script start
Timing: Jan 18 2025 18:16:44
Module start 'layout'
Timing: Jan 18 2025 18:16:44
Module start 'content'
Timing: Jan 18 2025 18:16:45
Module end 'content'
Timing: Jan 18 2025 18:16:45
Script end

Main resources:

Total runtime1.6456 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.1719152.6563
Module start 'layout' 0.00680.0045 740.828139.5078
Module start 'content' 0.01131.6325 780.3359580.1641
Module end 'content' 1.64380.0017 1,360.500012.0938
Script end 1.6455  1,372.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.2126160.0002
Check MTime0.00150.0907160.0001
Mysql Total
Database connection0.00120.074310.0012
Mysqli_queries1.580496.0367590.0268
Looping result0.00080.0463570.0000
Template Total1.604497.520.8022
Template load0.00220.134820.0011
Template processing1.602297.364420.8011
Template load and register function0.00010.006410.0001
states
state_id_array0.00180.108410.0018
state_identifier_array0.00320.195420.0016
Override
Cache load0.00190.1133290.0001
Sytem overhead
Fetch class attribute can translate value0.00170.104930.0006
Fetch class attribute name0.00140.087050.0003
XML
Image XML parsing0.00140.087430.0005
class_abstraction
Instantiating content class attribute0.00000.000450.0000
General
dbfile0.00210.1299220.0001
String conversion0.00000.000440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs