Summary: Easily define text blocks/snippets and insert them in the wiki page with a button
Version: 20230403
Prerequisites: PmWiki 2.2.56 or newer
Status: Experimental
Maintainer: Petko
License: GNU GPLv3+
Categories: Editing
Users: (view? / edit)


The recipe allows definition of GUIButtons with PageTextVariables.


  1. Edit your wiki page [[Site.GUIEditSnippets]] and place such text:
    (:mtext1:Here is some
    multiline text.:)
  2. Place guieditsnippets.phpΔ into your pmwiki/cookbook directory
  3. Add to config.php such lines:
    if($action=='edit') include_once("$FarmD/cookbook/guieditsnippets.php");
    # The way you usually add GUI buttons:
    $EnableGUIButtons = 1;
    $GUIButtons['ins'] = array(900, '$:ins1', '$:ins2', '$[ins]', '$GUIButtonDirUrlFmt/ins.gif"$[ins]"');
    $GUIButtons['del'] = array(901, '$:del1', '$:del2', '$[del]', '$GUIButtonDirUrlFmt/del.gif"$[del]"');
    $GUIButtons['mtext'] = array(902, '$:mtext1', '$:mtext2', '$[mtext]', '$GUIButtonDirUrlFmt/mtext.gif"$[mtext]"');
    $GUIButtons['b1'] = array(903, '$:b1_before', '$:b1_after', '$:b1_default', '$:b1_icon');

To learn about $GUIButtons definitions, see the files docs/sample-config.php, scripts/guiedit.php or PmWiki.SampleConfigFile; notably you need to have the buttons prepared.

The difference with the usual $GUIButtons feature is that you can define PageTextVariables from a predefined page, whose text/value will be inserted when the editor clicks on the button: '$:ins1', '$:ins2', '$:del1', '$:del2', '$:mtext1', '$:mtext2' from the page Site.GUIEditSnippets.

If a PageTextVariable is not set in that page, the button will insert empty string (nothing): like above the '$:mtext2' variable is not defined.


To change the default page containing the snippets, set in config.php $GUIEditSnippetsPage:

  $GUIEditSnippetsPage = 'Site.OtherPage';

That page needs to be readable for the editors.



  • If you define the icon with a page text variable, the quotes delimit the tooltip title. If you need to have a quote in the tooltip title, replace it with ".

Change log / Release notes

  • 20230403: Update for PmWiki 2.3.15 and more recent (bug reported by Martin Cuno).
  • 20191204: It is now possible to define the default text (if no text is selected) and the iconĀ±title of the button with page text variables (requested by Martin Cuno).
  • 20160402: First public release, ready to be tested.

See also


  • Recipe written and maintained by Petko.


See discussion at GUIEditSnippets-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.