EditFormSamples

Summary: Provide administrators and authors with examples and instructions for replacing or customizing their site's Site.EditForm.
Version: pmwiki-2.1.10 and up
Maintainer: whomever is interested

Questions answered by this recipe

How can I replace or customize my Site.EditForm?

Description

Provide administrators and authors with examples and instructions for replacing or customizing their site's Site.EditForm.

Answer

  • Working within the wiki, you have two options:
    1. modify Site.EditForm to your needs,
    2. create Site.EditForm1, Site.EditForm2, etc, and add conditional statements in the original Site.EditForm to determine which form is displayed.
  • Working on the server-side as well as within the wiki, you have at least two options:
    1. place a custom EditForm page somewhere and add a line in config.php to point to (for instance) Site.Custom-EditForm:
        $PageEditForm = 'Site.Custom-EditForm';
  1. use the procedures discussed on these pages to allow individual authors to customize their own EditForms: Cookbook.UserConfigurations, PmWiki.SitePreferences and Site.Preferences

EditForm Samples

Wide EditForm

Site.Gemini-EditForm is a wide edit form with an extra row of buttons above the edit textbox. It suppresses the sidebar and the titlebar to maximise editing space.

Popup-EditForm

An EditForm in which the preview and quickhelp pane pops up on top of the edit textbox. No more downscrolling is necessary to view the preview.

The EditForm has a wide edit textbox with buttons to Save, Save&Edit etc both above and below it. For browsers not supporting javascript the preview and quickhelp is displayed as standard below the edit box.

To install download popupedit.zipΔ and extract to cookbook/popupedit/ directory, and install by adding to config.php:

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

In addition the script needs showhide.phpΔ installed to provide the toggle buttons (See ShowHide).

The script sets the Editform to Site.Popup-EditForm, which is added via a page store subdirectory. It also handles the switching for non-javascript browsers to use different styles. A narrow Popup-EditQuickRef page is used for the popup help.

Included in the zip is also an alternative version popup2edit.php which will load the styles needed from separate stylesheets. These need copying to Farmpub/css/

The styles are optimised for display in Gemini, Fixflow and Triad skins. For other skins some small adjustments of the values to position the preview optimally may be necessary.

Preview with every edit

You can replace part of the markup on the Site.EditForm to force the display of the page preview whenever ?action=edit.

Edit the existing Site.EditForm and make the following replacement in its text:

Original

(:if e_preview:)
!!$[Preview {$FullName}]
'''$[Page is unsaved]'''
(:e_preview:)
----
'''$[End of preview -- remember to save]'''\\
[[#top | $[Top] ]]
(:if:)

Preview Cookbook.EditFormSamples

Page is unsaved (:e_preview:)


End of preview -- remember to save
Top

Replacement (note that the (:markup:)...(:markupend:) markup doesn't work for this)

(:if e_preview:)
!!$[Preview `{$FullName}]
'''$[Page is unsaved]'''
(:e_preview:)
----
'''$[End of preview -- remember to save]'''\\
(:if ! e_preview:)
----
!!$[Preview `{$FullName}]
(:include {$FullName}:)
----
'''$[End of preview -- remember to save]'''\\
(:if:)

[[#top | $[Top] ]]

Make "minor edit" the default save behavior

Edit the Site.EditForm page, and change the

   (:input e_minorcheckbox:)

to be

   (:input e_minorcheckbox checked=1:)

Warn user when editing and saving a new page will create a new wiki group

Display a warning when a user is creating a page in a non-existent wiki group.

  1. Create a warning page.
  2. Edit Site.EditForm to include the new warning page under the condition that the page being edited is in a group that has no Group.RecentChanges page.

Details appear on Cookbook:NewGroupWarning.

Add labels to the edit form to make it more accessible

  • Cookbook:FormExtensions is required. Once installed, the relevant part of your edit form should look something like:
(:label e_changesummary $[Summary]::) (:input e_changesummary id="e_changesummary":)\\
(:label e_author $[Author]::) (:input e_author id="e_author":) (:input e_minorcheckbox id="e_minorcheckbox":) (:Label e_minorcheckbox $[This is a minor edit]:)\\

See Also

Contributors

HansB, TeganDowling

Comments

See discussion at EditFormSamples-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.