Don't pass the $out variable in the function call, instead get it from the
global $FmtV['$PageText'] variable.
So, have something like this:
...
$HandleBrowseFmt = array('function:PrintJSON()');
...
print json_encode($GLOBALS['FmtV']['$PageText']);
# or global $FmtV; print json_encode($FmtV['$PageText']);
There is more than one way to do it.
The BlogIt and the Qnotes recipes update parts of a page via Ajax, you may
look how they do it. Someone asked about Ajax in PmWiki before and this was
reportedly useful:
http://thread.gmane.org/gmane.comp.web.wiki.pmwiki.user/53499/focus=53520
Petko
Peter Bowers writes:
I am putting together a web-site where the help is served in a jsquery-ui
dialog populated by AJAX. Up until now I've coded the help in HTML and just
put it directly in PHP variables. As the site matures the documentation is
growing rapidly and maintaining it in HTML is getting a bit onerous -- it
would be great if I could maintain the docs in pmwiki.
In order to serve just the page text I've created an action handler. I could
totally replace HandleBrowse() if necessary, but it feels like I should be
able to just set a couple configuration variables and re-use that
functionality.
When I do this:
===(snip)===
function HandleAJAXPageText($pagename, $auth = 'read')
{
global $HandleBrowseFmt;
$HandleBrowseFmt = array('function:PrintJSON($PageText)');
HandleBrowse($pagename, $auth);
}
function PrintJSON($pagename, $out)
{
header("Content-type: application/json");
print json_encode($out);
}
===(snip)===
The $PageText ends up getting replaced by the contents of the web-page and
then the 'function:PrintJSON(hello this is the text on the page)' no longer
matches the regex for a valid function and the function is never called. I
end up getting a web-page that includes the PrintJSON( ... ) function call as
part of the text on the page served.
(The relevant part of pmwiki code is in pmwiki.php around line 1182 - in the
PrintFmt() function.)
I tried various ways of getting the 'function:PrintJSON(...)' to pass the
variable $PageText rather than the contents of it, but I'm not making any
progress...
Any ideas?
-Peter
_______________________________________________
pmwiki-devel mailing list
pmwiki-devel@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel