eZ Community » Forums » Discussions » ezjscore: eZ Publish JavaScript and...
expandshrink

Wednesday 23 December 2009 7:45:21 pm - 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.

Saturday 26 December 2009 1:42:16 pm

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 blunk.gif Emoticon).

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 ?

Tuesday 29 December 2009 1:00:08 pm

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

Tuesday 29 December 2009 3:59:11 pm

Thanks André ! I didn't catch it happy.gif Emoticon

Friday 12 February 2010 12:21:03 pm

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

Friday 12 February 2010 5:32:06 pm

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!

Saturday 13 February 2010 4:08:13 am

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

Modified on Saturday 13 February 2010 4:08:43 am by paul bolger

Sunday 14 February 2010 5:10:10 am

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

Monday 15 February 2010 10: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,

Saturday 20 February 2010 2:06:20 pm

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" ...

Wednesday 24 February 2010 6:28:31 am

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.

Modified on Wednesday 17 March 2010 9:30:26 am by paul bolger

Wednesday 24 February 2010 8:45:31 am

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

Cheers !

Saturday 27 February 2010 10: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 )

Tuesday 02 March 2010 11: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( blunk.gif Emoticon ), so take a look at some tutorials for jQuery or YUI 3.x.

Tuesday 02 March 2010 6:04:55 pm

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?

Modified on Monday 08 March 2010 11:13:39 pm by Jordan Hirsch

Tuesday 31 May 2011 1:14:50 pm

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 !

Tuesday 31 May 2011 11: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 blunk.gif Emoticon
  • 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
expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from