How to return Smarty template in json array?
for example:
PHP:
$smarty=new Smarty();
....
$title='some text';
echo json_encode(array('title'=>$title,'page'=>$smarty->display('templatename.tpl')));
jQuery:
$.post('pages.php',{id:id,page:page},function(json){
$('.title').text(json.title);
$('.content').html(json.page);
},'json');
Smarty’s display() echos the rendered template to the outbut buffer. You’re probably looking for fetch() to get the rendered template as string.