Topic: Use any Smarty Plugins with Xajax
This example shows how to use any smarty Plugin with xajax.
The trick is to include the plugin directly and to use a buffer.
If the plugin only returns a value you need no buffer and can work
$out = smarty_plugin(.....) ;
Code: PHP
function forum($params)
{ global $smarty,$xajax;
$tagid = isset($params['tagid']) ? RemoveXSS($params['tagid']):'rssfeed';
$urlid = isset($params['urlid']) ? RemoveXSS($params['urlid']):0;
if ($urlid==1)
$url = 'http://forum.powercms.org/index.php?action=.xml;board=15;type=rss;'; // Stammtisch
elseif ($urlid==2)
$url='http://forum.powercms.org/index.php?action=.xml;board=49;type=rss;'; // Version Leipzig
elseif ($urlid==3)
$url='http://forum.powercms.org/index.php?action=.xml;board=3;type=rss;'; // Tipss und Tricks
elseif ($urlid==4)
$url='http://forum.powercms.org/index.php?action=.xml;board=4;type=rss;'; // Show Off
else
$url = 'http://forum.powercms.org/index.php?action=.xml;board=15;type=rss;'; // wie 1
// Buffer muss gestartet werden, da pirss eine Ausgabe und keine Rückgabe macht
ob_start();
@require_once('lib/smarty/plugins/function.pirss.php');
smarty_function_pirss(array("url"=>$url),$smarty);
$out=ob_get_contents();
ob_end_clean();
$objResponse = new xajaxResponse();
$objResponse->assign($tagid,"innerHTML",$out);
return $objResponse;
}
Last edited by czarnowski (2009-03-06 10:50:22 AM)