[Pmwiki-users] Page preview can now be implemented rather easy

Bernhard.Weichel at t-online.de Bernhard.Weichel at t-online.de
Sun Jun 15 14:28:26 CDT 2003


Hello Patrick,

due to the new features in 0.5.x (in particular PrintText) it is now
possible to implement the highly desired page preview feature. Here is the
code, I am using.

 else if ($myaction=="edit" | $myaction=="preview")
   {
    global $HTTP_POST_VARS, $Text;
    $newtext=$HTTP_POST_VARS["text"];     // don't know how the text should
be processed
                                          // it seems that fixing inlines
must be done here
    if ($newtext=="") {$newtext=$Text;}   // if preview was called directly,
not via edit

    if ($myaction=="preview") {PrintText($pagename, $newtext);}

    PrintFmt($pagename, "<form name='edit' action='$PreviewUrl'
method='post' onSubmit='return true;'>
      <input type='hidden' name='pagename' value='\$PageName' />
      <input type='hidden' name='action' value='post' />

      <p><a href='\$ScriptUrl/PmWiki/TipsForEditing'>Hinweise</a>
        <a
href='\$ScriptUrl/PmWiki/TextFormattingRulesDe'>Textformatierung</a>
        <input type='submit' value=' Save ' />
        <input type='submit' value='Preview'
onclick=\"document.edit.action.value='preview';\" />
        <input type='submit' value='Reset'
onclick=\"document.edit.action.value='browse';\" />
      </p>
      <p><textarea style='WIDTH: 100%' name='text' rows='25' cols='800'
        onkeydown='if (event.keyCode == 27)
event.returnValue=false;'>$newtext</textarea><br /></p></form>
       ");
     PrintFmt($pagename, "wiki:PmWiki.EditQuickReference");
   }

preview works because the pmwiki.php does not get the "post" action. It is
all handled in my browseformat.php.

you can see it in action in
http://www.b-weichel.2in.de/rittertag/pmwiki.php/Main/HomePage

for some reason, inline markup does not work. In particular each push to
preview quotes the "'" and subsequently the quote of the quote ...

As I do not really know what I am doing, I assume the code is neither
elegant nor sufficient ...


--Bernhard





More information about the pmwiki-users mailing list