Fox Page Management

Summary: creating new pages, new groups and copying pages with Fox forms Version: Prerequisites: pmwiki 2.2.0 beta Status: Maintainer: HansB? Categories: Forms Fox

Description

SomeExamples of page management using Fox forms

New Page Form

You can build a new page form using Input? directives and Fox form processor.

Example 1:

FoxNewPageBox opens new page in edit mode.
If page exists it will jump to target page. It will load content from a template page into the new page.

(:fox box1 template=Site.NewPageTemplate:)
(:input text newedit size=20:)(:input submit post "Create Page":)
(:foxend box1:)

Example 2

FoxNewPageBox saves new page with template string inserted.
If page exists it will append template string to existing target page.

(:fox box2 redirect=1:)
(:foxtemplate '''New Page''' :)
(:input text target size=20:)(:input submit post "Create Page":)
(:foxend box2:)

Copy Page Form

A simple form to copy a page to a different name

(:foxmessage:)
(:fox cpform foxaction=copy foxgroup={$Group}:)
Copy page (:input text template :) to (:input text target :) (:input submit post Copy:)
(:foxend cpform:)

New Group Form

Here are some examples how to build forms for multiple page creation, using Fox and Input? controls. Note that you may need to set explicit page permissions for creating pages in other groups. This is easiest by adding to Site.FoxConfig. See Fox#security about $FoxPagePermissions.

A NewGroupBox creating pages A,B and C from one template, and redirecting to page A.

(:fox box1 target=A,B,C template=Templates.OneForAll redirect={$$foxgroup}.A:)
(:input text foxgroup "":)
(:input submit post "New Group":)
(:foxend box1:)

A NewGroupBox creating pages A,B,C from corresponding template pages TA,TB,TC:

(:fox box2 target=A,B,C template=Templ.TA,Templ.TB,Templ.TC redirect={$$foxgroup}.A:)
(:input text foxgroup "":)
(:input submit post "New Group":)
(:foxend box2:)

Or alternatively:

(:fox box3 redirect={$$foxgroup}.A :)
(:foxpost Templ.TA=TargetA Templ.TB=TargetB Templ.TC=TargetC :)
(:input text foxgroup "":) (:input submit post "New Group":)
(:foxend box3:)

Creating a page with a serial number in name

You need to download and install Attach:serial.php Δ to add new markup expressions which will be used to calculate the next serial number. Please see detailed description at Serial Page Names?

The following form will display just a button. When clicked the form will create a new serial page in group ToDo using the Name part prefix of Jack-, basing the new page on a template page Site.ToDoTemplate. The user will be redirected to the new page.

(:foxmessage:)
(:fox newtodo template=Site.ToDoTemplate redirect=1:)
(:input hidden target '{$$(serialname ToDo Jack- )}':)
(:input submit post "Create New ToDo Page":)
(:foxend newtodo:)

Note that the serialname expression is enclosed in hyphens, and that it is used here as a replacement variable {$$(serialname ...)} and not as a normal markup expression {(serialname ....)}. Normally markup expressions will be evaluated when the page is loaded, whereas the expression written as a replacement variable will only be evaluated when the form is processed, thereby overcoming possible conflicts of page names if another user is creating a page at about the same time.

Creating a Profile page and Preferences page

A logged in author can create a Profiles and Preferences page by clicking one button:

(:fox form1 redirect="Profiles.{$Author}" pagecheck="Profiles.{$Author}":)
(:foxpost Templates.AuthorTemplate=Profiles.{$Author} :)
(:foxpost Templates.AuthorPreferencesTemplate=Profiles.{$Author}-Preferences :)
(:input submit post "Create Profile Page":)
(:foxend form1:)

To set the edit password to id:$AuthId, i.e., the logged in user creating his profile using this box, you can use the foxfilter capability. Download Attach:foxsetpwedit.php Δ, store it in your cookbook directory and add to your local/config.php:

include_once("$FarmD/cookbook/foxsetpwedit.php");

and add:

(:input hidden foxfilter FoxSetPW:)

to the form markup above. Vince

One click page delete action link

You can add a page delete link to your page actions. For security perhaps conditionally display it only for admins.

Configure permissions:
To allow the delete link to work set in config.php $EnableFoxUrlInput = 'true'; and set $FoxPagePermissions for the groups you like to enable the delete link to 'replace' or 'all'. Note that the 'replace' foxaction can be used very mischieviously, much more than the 'add' foxaction. You may want to set this only for users with edit access:

if (CondAuth($pagename,'edit')) {
   $EnableFoxUrlInput = 'true';
   $FoxPagePermissions['*.*'] = 'all'; 
}

Create the action link, perhaps add to page Site.PageActions, or the footer action menu in Gemini, FixFlow or Triad skins Site.PageFootMenu: (note the following link code should be just on one line, I cut it into two to stop the page becoming too wide)

(:if auth admin:)
*%rel=nofollow%[[{*$FullName}?action=foxpost&foxaction=replace&put=overwrite
&target={*$FullName}&foxtemplate=delete&post=1&redir=1| $[Delete] ]]
(:ifend:)

Its a long bit of code, but the link just says Delete. It replaces a whole fox form. On clicking the page delete word inside the template gets written to the page, and so the page is deleted with one click.

Delete Multiple Pages Form

This form will delete multiple pages when a wiki page pattern is entered into the input field. The PowerTools recipe needs to be installed, which provides the plist markup expression used in the form. Page permissions need to be set of course to allow foxaction 'replace'. The page content gets replaced by the word delete, which will result in the page delete.

(:messages:)
(:fox delfrm foxaction=replace put=overwrite  target='{$$(plist {$$pages})}' foxsuccess='page deleted':)
(:foxtemplate "delete":)
Delete Pages: (:input text pages:) (:input submit post Enter:)
(:foxend delfrm:)

Delete multiple pages with checkbox selection

This form will generate a pagelist of the pages in the group entered into the text field. Each page name will have a checkbox, and a delete button at the bottom will delete all pages selected by checking their boxes. This recipe needs PowerTools installed.

Sourcecode of the form and pagelist template:

(:foxmessage:)
(:fox dellist foxaction=display:)
(:foxtemplate "{$$(pagelist group={$$group} fmt=#delete)}":)
Group: (:input text group:) (:input submit post 'Make Del List':)
(:foxend dellist:)
(:foxdisplay dellist:)

(:if false:)
[[#delete]]
(:template first:)
(:fox delform foxaction=replace put=overwrite foxsuccess='Deleted page' foxfailure='Not deleted page':)
(:foxtemplate "delete":)
||
(:template defaults :)
||[[{=$FullName}]] ||(:input checkbox target[] {=$FullName}:) ||
(:template last:)
|| Delete all:(:input checkbox target '{$$(plist {$$group}.*)}':)||(:input submit post Delete:) ||
(:foxend delform:)
[[#deleteend]]
(:ifend:)

Comments

See Also

  • Serial Page Names? - how to create serial number page names which automatically increase the serial number part.
  • Fox

Contributors