Wednesday 23 December 2009 10:45:21 am - 16 replies

» Read full tutorial

Introduction

ezjscore is an eZ Publish extension that provides a simple framework for using Ajax, JavaScript, and (to a smaller extent) CSS. It is bundled with eZ Flow and Website Interface installations in eZ Publish 4.2 and is mostly compatible with previous eZ Publish 4.x versions. In this article, we will provide documentation for ezjscore and show you some example code, all with the goal of helping you to build more powerful, richer, and better performing eZ Publish websites.

Author Message

Jérôme Vieilledent

Saturday 26 December 2009 4:42:16 am

Thanks Łukasz and André for this article. This extension is really useful ! I now use it on all my projects (novenimagecropper has a dependency on it ;)).

JS/CSS Concatenation is great, but it could be interesting to be able to take into account modification time for the hashname generation, in order to get better support for browser cache issues and CDNs. What do you think ?

André R.

Tuesday 29 December 2009 4:00:08 am

@Jérôme: There is a issue for that, add your comments there -> http://issues.ez.no/IssueView.php?Id=15811&

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

Jérôme Vieilledent

Tuesday 29 December 2009 6:59:11 am

Thanks André ! I didn't catch it :)

paul bolger

Friday 12 February 2010 3:21:03 am

Is it possible to put an override for ezjscore.ini in a design extension, or in the main settings section?

Paul Bolger

Nicolas Pastorino

Friday 12 February 2010 8:32:06 am

"

Is it possible to put an override for ezjscore.ini in a design extension, or in the main settings section?

"

Hi Paul !

Yes, it totally is, it is just a normal configuration file, meaning it complies with the general rules of INI overrides. I am not sure what you mean by "main settings section", but if this is <ezroot>/settings/override or <ezroot>/settings/siteaccess/<siteaccess_name>/ then it is just OK (but not directly in <ezroot>/settings/, where only default configuration files are to be stored, which i am sure you already know ).

Cheers!

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

paul bolger

Friday 12 February 2010 7:08:13 pm

Hi Nicolas,

That's good news!

I'm still a bit hazy about what happens when one is using a design extension though. Can you override settings for one extension in another?

Would any of these work?

/extension/ezwebin_custom/settings/ezjscore.ini.append.php

/extension/ezwebin_custom/design/ezwebin/settings/ezjscore.ini.append.php

/extension/ezwebin_custom/design/ezwebin/settings/mysiteaccess/ezjscore.ini.append.php

Regards

Paul Bolger

Paul Bolger

paul bolger

Saturday 13 February 2010 8:10:10 pm

What's the recommended way to include or exclude css and javascript files?

Paul Bolger

Nicolas Pastorino

Monday 15 February 2010 1:14:23 am

"

Would any of these work?

/extension/ezwebin_custom/settings/ezjscore.ini.append.php

/extension/ezwebin_custom/design/ezwebin/settings/ezjscore.ini.append.php

/extension/ezwebin_custom/design/ezwebin/settings/mysiteaccess/ezjscore.ini.append.php

"

Hi Paul,

The first one above is correct, acting as a global override (like if the override file was located in <ezroot>/settings/override/).

The second one is incorrect: a configuration file, and by extension a 'settings' directory, can not be placed in a design directory.

Same answer for the 3rd option above.

Per your question : "Can you override settings for one extension in another?", you sure can. I'd recommend to have a look at this thread : http://share.ez.no/forums/setup-design/ini-settings-override-order , will shed the final light on your interrogations.

cheers Paul,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Marco Zinn

Saturday 20 February 2010 5:06:20 am

Thanks for this article.

What i was looking for (and did not find yet): A simple example on how to call simple YUI / jquery functions like "show/hide a DIV" using one of the libraries.

I.e. : does somebody have some example for this using ezjscore somewhere?

I created this using scriptaculous/prototype earlier, but i assume, one of these "bundled" libraries also is able to do these "easy JS animation effects" ...

Marco
http://www.hyperroad-design.com

paul bolger

Tuesday 23 February 2010 9:28:31 pm

Hi Nicolas,

It took me a while to work out how to tell if my settings override was working or not, but I have it working now. Note, for anyone else doing this, that the order of your extensions in your /site/override/site.ini.append.php file affects the priority or cascade of the ini files. Contrary to Łukasz's blog my extensions seem to work in reverse order, the higher in the list the higher priority.

Here's my extension settings block.

 [ExtensionSettings]
ActiveExtensions[]
ActiveExtensions[]=ezwt
ActiveExtensions[]=ezstarrating
ActiveExtensions[]=ezgmaplocation
ActiveExtensions[]=ezoe
ActiveExtensions[]=ezodf
ActiveExtensions[]=ezmultiupload
ActiveExtensions[]=ezwebin_custom
ActiveExtensions[]=ezwebin
ActiveExtensions[]=ezjscore

Also, I've noticed that if you activate an extension in the admin interface, rather than by editing the site.ini directly, eZ Publish seems to get creative with the order - which can wreak havoc on your site.

Paul Bolger

Nicolas Pastorino

Tuesday 23 February 2010 11:45:31 pm

Thanks Paul for sharing the output of your investigations, this is very helpful !
And good to hear you got it to work.

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Serhey Dolgushev

Saturday 27 February 2010 1:21:18 pm

Hi!

As i can see, now all methods wich are mapped to AJAX calls are static. And we cant get a current instace ($this). But if you change some code in ezjscServerRouter::call() it will became possible:

line 241:

return call_user_func_array( array( $this->className, $this->functionName ), array( $this->functionArguments, &$environmentArguments, $isPackeStage ) );

to

return call_user_func_array( array( new $this->className, $this->functionName ), array( $this->functionArguments, &$environmentArguments, $isPackeStage ) );

In this case we can put some usefull code in ezjscServerFunctions::__constructor wich will parse POST vars, for example (but to get them, all AJAX mapped methods shouldn`t be static )

André R.

Tuesday 02 March 2010 2:14:21 am

"What i was looking for (and did not find yet): A simple example on how to call simple YUI / jquery functions like "show/hide a DIV" using one of the libraries."

Hi, we are not planning on documenting the libraries( ;) ), so take a look at some tutorials for jQuery or YUI 3.x.

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

Jordan Hirsch

Tuesday 02 March 2010 9:04:55 am

Great article, the only thing I think it's missing more of a real-world example. For instance, it would be great to see an example of how to use this to submit a Poll object from the embed view and get back the poll results without refreshing the entire page. Is that something you can do with ezjscore?

Me: http://jordan.teamhirsch.com
My blog: http://wiredformusic.blogspot.com
My other company: http://thinkimprov.com
eZ Certification: http://auth.ez.no/certification/verify/402488
eZ Award: http://ez.no/company/news/ez_awards_2007_prize_winners

Thibaut Marin-Cudraz

Tuesday 31 May 2011 4:14:50 am

I agree with you Lordan, I'm looking for an extension which can load some Ajax content but still haven't find the simple/clean/efficient extension. If anyone has a concrete exemple ? Thanks !

Thibaut Marin-Cudraz
WEB | DESIGN | MULTIMEDIA | MUSIC
06 24 68 80 67
thibaut@thisishellow.com
www.thisishellow.com
facebook.com/pages/Hellow/164261953617878
twitter.com/thibautmc

Gaetano Giunta

Tuesday 31 May 2011 2:54:01 pm

@thibaut: for ajax content you're completely spoiled nowadays:

  • use soap (does a javascript client even exist? hahaha): write a php function for every soap method exposed
  • use xmlrpc/jsonrpc: install the ggsysinfo extension, code exposed webservices as php functions, js client can be any supporting those standard protocols (but a client js class based on YUI is also included), permission checking as bonus
  • use ezjscore: similar to xmlrpc/jsonrpc, main difference being usage of a custom wire protocol (and templates can be used to implement the exposed services - crazy!)
  • use json templates for custom content views (see eg. ggxmlview extension)
  • expose all existing fetch functions as xmlrpc/jsonrpc/ezjscore methods without writing a single line of code: use the ezwebservicesapi extension. Then write your custom fetch functions ;-)
  • last but not least, use the new rest api. Faster and less memory hungry than other methods, it might still be a little lacking in permission checking and cache purge capablities

Principal Consultant International Business
Member of the Community Project Board

You must be logged in to post messages in this topic!

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 04:54:54
Script start
Timing: Jan 18 2025 04:54:54
Module start 'layout'
Timing: Jan 18 2025 04:54:54
Module start 'content'
Timing: Jan 18 2025 04:54:55
Module end 'content'
Timing: Jan 18 2025 04:54:55
Script end

Main resources:

Total runtime0.3650 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.0625152.6406
Module start 'layout' 0.00540.0032 740.703139.4766
Module start 'content' 0.00860.3551 780.17971,195.5938
Module end 'content' 0.36370.0013 1,975.773447.6484
Script end 0.3650  2,023.4219 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.9361160.0002
Check MTime0.00130.3639160.0001
Mysql Total
Database connection0.00090.240810.0009
Mysqli_queries0.206256.50081410.0015
Looping result0.00160.44591390.0000
Template Total0.333691.420.1668
Template load0.00220.603820.0011
Template processing0.331490.791220.1657
Template load and register function0.00020.044710.0002
states
state_id_array0.00110.295920.0005
state_identifier_array0.00100.281130.0003
Override
Cache load0.00230.61661040.0000
Sytem overhead
Fetch class attribute name0.00190.5105260.0001
Fetch class attribute can translate value0.00080.215390.0001
class_abstraction
Instantiating content class attribute0.00010.0193330.0000
XML
Image XML parsing0.01524.168090.0017
General
dbfile0.01273.4758680.0002
String conversion0.00000.002940.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.tplforum_topic/full.tplextension/community_design/design/suncana/override/templates/forum_topic/full.tplEdit templateOverride template
17content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
21content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
16content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 65
 Number of unique templates used: 11

Time used to render debug report: 0.0001 secs