How to include a library in a template ?

Author Message

Anthony M.

Wednesday 23 January 2008 8:41:17 am

Hi,
is it possible to include a javascript library as Ext ou Dojo in a template ?

thanks

Anthony

Pascal Specht

Friday 25 January 2008 12:48:08 am

Hi Anthony,

definitively yes:

{literal}
<script type="text/javascript">
<!--
your code
--!>
{/literal}

and also, you may use the feature in your pagelayout file:

{foreach ezini( 'JavaScriptSettings', 'JavaScriptList', 'design.ini' ) as $script}
    <script language="javascript" type="text/javascript" src={concat( 'javascript/', $script )|ezdesign}></script>
{/foreach}

Maxime Thomas

Friday 25 January 2008 4:25:59 am

Note that you will have some troubles with bracket if you would like to customize your JavaScript function with eZ variables. I mean, that the code below will fall in error :


<script type="text/javascript">
<!--
function myFunction(var1, var 2)
{

alert({$mytext});

}
--!>

Prefer this :

{literal}
<script type="text/javascript">
<!--
function myFunction(var1, var 2)
{
{/literal}
alert({$mytext});
{literal}
}
--!>
{/literal}

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Betsy Gamrat

Sunday 02 March 2008 6:24:19 am

Another way to add template data into javascript code is:

<script>
var javascript_variable={$template_variable};
{literal}
function javascript_function()
{
  alert(javascript_variable);
}
{/literal}
</script>

I have been using dojo with Smarty (http://smarty.php.net) and it is excellent. Take advantage of the themes, because they are very nice. It might be good to create a datatype that can do regular expression validation with dojo, using the "ValidationTextBox".

Good luck.

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 05:11:49
Script start
Timing: Jan 18 2025 05:11:49
Module start 'layout'
Timing: Jan 18 2025 05:11:49
Module start 'content'
Timing: Jan 18 2025 05:11:50
Module end 'content'
Timing: Jan 18 2025 05:11:50
Script end

Main resources:

Total runtime0.9179 sec
Peak memory usage4,096.0000 KB
Database Queries64

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 588.0313152.6406
Module start 'layout' 0.00650.0042 740.671939.4609
Module start 'content' 0.01070.9056 780.1328634.8672
Module end 'content' 0.91630.0016 1,415.000012.1406
Script end 0.9179  1,427.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.3881160.0002
Check MTime0.00140.1497160.0001
Mysql Total
Database connection0.00060.068410.0006
Mysqli_queries0.856693.3234640.0134
Looping result0.00080.0887620.0000
Template Total0.859293.620.4296
Template load0.00330.355020.0016
Template processing0.855993.243220.4280
Template load and register function0.00020.025710.0002
states
state_id_array0.00120.136010.0012
state_identifier_array0.00200.213620.0010
Override
Cache load0.00240.2631250.0001
Sytem overhead
Fetch class attribute can translate value0.00090.092940.0002
Fetch class attribute name0.00210.229870.0003
XML
Image XML parsing0.00140.156540.0004
class_abstraction
Instantiating content class attribute0.00010.006870.0000
General
dbfile0.00100.1108280.0000
String conversion0.00000.001240.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/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: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs