ezjscore server functions reference
Part 8, reference 19. A server function is a PHP method the browser can call through /ezjscore/call/... and get JSON
back. Building one is explained in Ajax with ezjscore server functions
and the tutorial An Ajax server function, by hand.
This page lists the settings, the built-in functions and the clients.
The settings block
In your extension's settings/ezjscore.ini.append.php, one block per server name:
| Key | Meaning |
|---|---|
[ezjscServer_<name>] | the block; <name> is the server name used in calls |
Class | the class whose public static methods are the functions (extends ezjscServerFunctions) |
File | the class's file, when it is not autoloaded |
TemplateFunction=true | the functions are templates, templates/<name>/<function>.tpl, instead of PHP methods |
Functions[] | the function list names this block belongs to, used by the ezjscore/call policy's limitation |
RequirePolicy | enabled: callers also need the ezjscore/call policy for this function list |
HardLimit | (ezjscnode only) the most items a subtree call returns |
The address
<root>/ezjscore/call/<server>::<function>[::<arg1>[::<arg2> ...]]The parts after the function name arrive in $args. POST data is read with eZHTTPTool in the method. The answer,
with an Accept: application/json header, is {"error_text":"...","content":...}.
Access
- Every call needs the policy
ezjscore/call; its limitation FunctionList names the function lists a role may call. - Each function must still check what it does: a function that reads content checks that the user can read it; one that changes data requires POST and the form token (ezformtoken and CSRF).
- The kernel's
ezjscnodefunctions are readable by anyone who may read the node unlessRequirePolicy=enabled; backend ezjscore services explains the switch.
Server functions the kernel ships
| Call | Returns |
|---|---|
ezjsc::time | the server time (a quick test) |
ezjscnode::subtree::<nodeID>[::<limit>::<offset>...] | a node list as JSON |
ezjsctemplate::<template> | a template rendered as the answer |
expsubitems::columns::<nodeID>, expsubitems::rows::... | the admin sub-items table's data |
expdebugbar::... | the debug bar's functions (settings, caches, log) |
The comments of extension/ezjscore/settings/ezjscore.ini give each block's test address.
Clients
| Client | Loaded with | Call |
|---|---|---|
| Exponential UI | exp::io (on every admin page) | Exp.io.call( 'myserver::myfunction', [ arg1 ], { data: { ... } } ) returns a Promise; POST by default |
| jQuery | ezjsc::jquery, ezjsc::jqueryio | $.ez( 'myserver::myfunction::arg1', postData, callback ) |
Both send the form token with POST requests from pages that carry it.
Related pages
- Previous: Content functions from PHP
- Next: ezformtoken and CSRF protection
- ezjscore
- The expui JavaScript API
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.