Forums / Discussions / ezjscore: eZ Publish JavaScript and Ajax framework

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!