Using Smarty Template Engine with Xajax Toolkit

Are you having a hard time making Smarty and Xajax to work together? Then, this guide is for you. Setting up Smarty and Xajax to work together requires no tricks but a lot of patience is a must.


< ?

/* include all the required functions and class files */

include('libs/smarty.class.php');

include('xajax.inc.php');

/* end */

/* instantiate the smarty templating engine */

$body = new Smarty();

/* end */

/* instantiate the ajax class and register functions*/

$xajax = new xajax();

/* debug output */

//$xajax->debugOn();

/* register your ajax functions */

$xajax->registerFunction(’addFormInput’);

$xajax->registerFunction(’processAddForm’);

/* end */

/* process ajax request then assign and call xajax javascript for your smarty template */

$xajax->processRequests();

$body->assign(’ajax_script’, $xajax->getJavascript());

$body->display(’index.html’);

?>

Lastly, call the ajax_script variable in your index.html template.

xajax template

Thats all about it.

Permalink • Print • Comment

Trackback uri

http://seoroot.com/blog/computing/using-smarty-template-engine-with-xajax-toolkit.html/trackback

Related Entries

1 Comment on Using Smarty Template Engine with Xajax Toolkit »

[…] Using Smarty Template Engine with Xajax Toolkit […]

Leave a Comment