A template for generating .js file

Author Message

Kevin Gaudin

Friday 05 September 2008 2:55:22 am

Hi,

What would be the best technique for creating a template to generate a .js file which has to be included in every page of my site ?

Thanks for your help !

Twitter: @kevingaudin

Pierre Tissot

Monday 08 September 2008 8:24:37 am

Hi,

I would create the javascript code that as to be dynamic on the template itself (inside a <script> tag)

PiR

André R.

Tuesday 09 September 2008 12:43:23 am

Or if your not afraid of writing php (doc, settings, code):
http://svn.projects.ez.no/ezcore/trunk/ezcore/doc/ezscript.txt
http://svn.projects.ez.no/ezcore/trunk/ezcore/settings/ezcore.ini
http://svn.projects.ez.no/ezcore/trunk/ezcore/classes/ezcoreservercallfunctions.php

However this is only useful if you need to generate a lot of js dynamically, for instance like OE 5.x does with translations:

http://svn.ez.no/svn/extensions/eztinymce/trunk/ezoe/classes/ezoepackerfunctions.php

So if you have mostly static js, with a couple of dynamic values from template, I would rather split out the static part into a external js file (unless it's small of course) and put the dynamic part in script tags in your pagelayout.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

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 30 2025 21:39:57
Script start
Timing: Jan 30 2025 21:39:57
Module start 'layout'
Timing: Jan 30 2025 21:39:57
Module start 'content'
Timing: Jan 30 2025 21:39:57
Module end 'content'
Timing: Jan 30 2025 21:39:57
Script end

Main resources:

Total runtime0.0181 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0035 588.1406151.2109
Module start 'layout' 0.00350.0027 739.3516220.7031
Module start 'content' 0.00620.0102 960.0547997.8047
Module end 'content' 0.01640.0017 1,957.859433.9922
Script end 0.0180  1,991.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002212.4185140.0002
Check MTime0.00105.3375140.0001
Mysql Total
Database connection0.00052.961810.0005
Mysqli_queries0.00168.634530.0005
Looping result0.00000.038310.0000
Template Total0.00137.010.0013
Template load0.00094.905910.0009
Template processing0.00042.081410.0004
Override
Cache load0.00063.426310.0006
General
dbfile0.00021.323880.0000
String conversion0.00000.027740.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