FoxPageManagement
Description
SomeExamples of page management using Fox forms.
Important: By default Fox is prohibited from posting to any page. $FoxPagePermissions need to be set with page patterns and associated actions for Fox to be able to do anything, with only a few exceptions! See Fox Security Configuration
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 newpagefrm1 template=Site.NewPageTemplate:) (:input text newedit size=20:)(:input submit post "Create Page":) (:foxend newpagefrm1:)
Example 2
FoxNewPageBox opens new page in edit mode with (:title PAGENAME:)
inserted.
Typing in page names with fancy characters in the title is possible. Note that posting of directives need to be enabled for this to work.
(:if auth edit:) (:fox newpagefrm2 template={$FullName}#newpage:) (:input text newedit size=20:)(:input submit post "Create Page":) (:foxend newpagefrm2:) [[#newpage]] (:title {$$newedit}:) [[#newpageend]] (:ifend:)
Example 3
FoxNewPageBox saves new page with template string inserted.
If page exists it will append template string to existing target page.
(:fox newpagefrm3 redirect=1:) (:foxtemplate '''New Page''' :) (:input text target size=20:)(:input submit post "Create Page":) (:foxend newpagefrm3:)
Copy Page Form
A 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 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 Security Configuration 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 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 {$$(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:)
See Also
- Serial Page Names - how to create serial number page names which automatically increase the serial number part.
- Fox
Contributors
Comments
See discussion at FoxPageManagement-Talk?