On Monday 09 February 2009 23:31:35 Etienne Convié wrote:
> 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();
...
> In a simple-code I would like to do this:
> $content = toHTML('<!--PageText-->'); but it seems to be not possible

Hi. There is MarkupToHTML().

You can check out how existing recipes or core scripts handle different 
actions, for a simplest example, see pmwiki/scripts/crypt.php.

You can do something like this (tested it, seems to work) :

  # I recommend an action more specific than 'ajax':
  $HandleActions['json'] = 'HandleJSONcontent'; # for ?action=json

  function HandleJSONcontent($pagename, $auth='read')
  {
        $page = RetrieveAuthPage($pagename,$auth,1, READPAGE_CURRENT);
        $toAJAX = array(
                'title' => array(
                'innerHTML' => PageVar($pagename,'$Titlespaced')
                ),
                'content' => array(
                'innerHTML' => MarkupToHTML($pagename, $page['text'])
                )
        );
        echo json_encode($toAJAX);
        exit();
  }

Hope that helps.
Petko

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to