How to ez-ajax my site

Author Message

Jorge estévez

Thursday 19 June 2008 8:49:44 am

Hello!

As far as I have read [ maybe not enough at all :-) ], to make my site work with ajax ( my site is ez v3.10 ) I have to install a basic extension first: xajax an then install ezxajax... ( at least this a solution I found hoping it works out )

What I have not found yet is where ot put the PHP code within Ez files ( not the extensions, read further ) and then access the code from an Ez publish template (.tpl) or any other link elsewhere.

I found the following code at the forum:

function xxxx($object_id) {

	// HTTP Response
	$objResponse = new xajaxResponse();
	
	// template init
	$tpl =& templateInit();
	
	// Add Variable to the template
	$tpl->setVariable('object_id', $object_id);

	// fetch template
	$html = $tpl->fetch(
"extension/mod_myextension/design/standard/templates/foo/bar.tpl" );

	$objResponse->addAssign("mydiv", "innerHTML", $html);
	
	// response
	return $objResponse;
}

So two issues here that I need to solve:

Where does this code can be placed.
How to invoke the function from an Ez publish template or any other link elsewhere.

thanks!

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Patrick Renaud

Tuesday 22 July 2008 8:51:02 am

Hello there !

I have the same kind of problem with almost exactly the same code as Jorge.
Using the xajax hello world contribution as a start, I'm trying to fetch and return some dummy template with ajax.
The problem is, when I put a templateInit instruction in my ajax code, it never returns...

Does anybody have a hint as to what to do to make it work ?

Ca, c'est fait !

Patrick Renaud

Tuesday 22 July 2008 9:09:37 am

A first answer : http://ez.no/developer/forum/developer/ajax_to_return_an_ez_publish_template_eg_new_comment

Ca, c'est fait !

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 11:44:15
Script start
Timing: Jan 18 2025 11:44:15
Module start 'layout'
Timing: Jan 18 2025 11:44:15
Module start 'content'
Timing: Jan 18 2025 11:44:16
Module end 'content'
Timing: Jan 18 2025 11:44:16
Script end

Main resources:

Total runtime0.9129 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 587.9063152.6250
Module start 'layout' 0.00720.0036 740.531339.4453
Module start 'content' 0.01080.9008 779.9766533.3359
Module end 'content' 0.91150.0013 1,313.312512.1719
Script end 0.9128  1,325.4844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4313160.0002
Check MTime0.00160.1745160.0001
Mysql Total
Database connection0.00120.136410.0012
Mysqli_queries0.852193.3484570.0149
Looping result0.00070.0732550.0000
Template Total0.873795.720.4368
Template load0.00260.281320.0013
Template processing0.871195.427020.4356
Template load and register function0.00040.041910.0004
states
state_id_array0.00140.154110.0014
state_identifier_array0.00150.163920.0007
Override
Cache load0.00230.2470220.0001
Sytem overhead
Fetch class attribute can translate value0.00130.140720.0006
Fetch class attribute name0.00300.324840.0007
XML
Image XML parsing0.00070.076620.0003
class_abstraction
Instantiating content class attribute0.00000.001950.0000
General
dbfile0.00080.0893150.0001
String conversion0.00000.001040.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs