[pmwiki-users] PmWiki in AJAX

Etienne Convié etienne at convie.net
Mon Feb 9 16:31:35 CST 2009


Hi again,

I found a piece of the solution of my problem. Maybe it would inspire 
someone to help me ;-)

In config.php I added:
if ($action == 'ajax') include_once($FarmD.'/cookbook/etco_AJAX.php');

In 'etco_AJAX.php' (recipe in cookbook directory):
ob_start();
HandleBrowse($pagename);
$content = ob_get_clean();

$toAJAX = array(
  'titleOfMyPage' => array(
    'innerHTML' => PageVar($pagename,'$Titlespaced')
  ),
   'contentOfMyPage' => array(
    'innerHTML' => $content
  )
);

echo json_encode($toAJAX);
exit();

For the titleOfMyPage I found with PageVar($pagename,'$Titlespaced') => 
OK, it is what I expected
I would like to do the same with the content of my page.

But:
1) in $content I do not have an html output... How can I do to have the 
HTML translation of a $page['text']?
2) I would like to not have exit(); at the end and to continue the 
process of the page, but if I don't do that, I have logically a warning 
'Headers already sent...'. How can I do to output json_encode($toAJAX) 
in place of my *.tmpl file at the end of the process?

In a simple-code I would like to do this:
$content = toHTML('<!--PageText-->'); but it seems to be not possible

Thanks a lot for helping me,
etco



More information about the pmwiki-users mailing list