[pmwiki-users] FOX-question: reading / writing plain text files ?

Knut Alboldt pmwiki at alboldt.de
Sat Feb 6 08:54:19 CST 2010

perfect !

Thanks a lot for your prompt answers. I just needed a few ideas and 
you've shown be some. I think from here I can start to get my things done.

I do know that pmwiki is very flexible, but every time I've to find out 
that it's even more ! (Thanks Pm !) But this also requires some deep 
knowledge of pmwiki.

I'll put this in a new recipe when it's ready, I'd like to put your 
answers on that recipe-page as well, if this is ok.

thanks a lot !


Am 06.02.2010 14:39, schrieb Hans:
> Saturday, February 6, 2010, 11:33:29 AM, Hans wrote:
>> PS: another approach might be to manipulate the $EditFunctions array.
>> Write a function which will save to text file (using the php functions
>> fopen, fwrite, fclose), add it to $EditFunctions array, and remove
>> 'PostPage' from it. This could be done without hacking fox.php.
> Just played with this idea. Here is a simple working example.
> The pub/textfiles/ directory needs to be created first.
> The idea is to use group 'Text' as target group, so when Fox gets
> target with 'Text' as group name, it will post the Name as text file.
> Make sure the Fox form has a 'group' field, to be set to 'Text'.
> $group = PageVar($pagename, '$Group');
> if ($action=='foxpost'&&  $_POST['group']=='Text') {
>    $FoxExcludeEditFunctions[] ='PostPage';
>    array_unshift($EditFunctions, 'PostTextFile');
> }
> function PostTextFile ($pagename, $page, $new) {
>    global $IsPagePosted;
>    $name = PageVar($pagename, '$Name');
>    $TextFilesDir = "pub/textfiles/";
>    $TextFilesExt = ".txt";
>    $filename = FmtPageName($TextFilesDir.$name.$TextFilesExt, $pagename);
>    $file = fopen($filename, "a+");
>    $text = $new['text'];
>    fwrite($file, $text);
>    fclose($file);
>    $GLOBALS['IsPagePosted'] = true;
> }
>    ~Hans

More information about the pmwiki-users mailing list