|
Cookbook /
FoxPageManagementSummary: creating new pages, new groups and copying pages with Fox forms
Version:
Prerequisites: pmwiki 2.2.0 beta
Status:
Maintainer: HansB
DescriptionSomeExamples of page management using Fox forms New Page FormYou can build a new page form using Input directives and Fox form processor. Example 1:FoxNewPageBox opens new page in edit mode. (:fox newpagefrm1 template=Site.NewPageTemplate:) (:input text newedit size=20:)(:input submit post "Create Page":) (:foxend newpagefrm1:) Example 2FoxNewPageBox opens new page in edit mode with (:fox newpagefrm2:)
(:foxtemplate "(:title {$$newedit}:)\n":)
(:input text newedit size=20:)(:input submit post "Create Page":)
(:foxend newpagefrm2:)
Example 3FoxNewPageBox saves new page with template string inserted. (:fox newpagefrm3 redirect=1:) (:foxtemplate '''New Page''' :) (:input text target size=20:)(:input submit post "Create Page":) (:foxend newpagefrm3:) Copy Page FormA simple form to copy a page to a different name (:foxmessage:)
(:fox copyfrm foxaction=copy foxgroup={$Group}:)
Copy page (:input text template :) to (:input text target :) (:input submit post Copy:)
(:foxend copyfrm:)
New Group FormHere 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 nameYou need to download and install powertools.phpΔ to add new markup expressions which will be used to calculate the next serial number. Please see detailed description at PowerTools 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 Creating a Profile page and Preferences pageA 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 linkYou can add a page delete link to your page actions. For security perhaps conditionally display it only for admins. Configure permissions: 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 FormThis 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 selectionThis 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:)
CommentsSee Also
Contributors |