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.