SimpleRecipeTemplate
Questions answered by this recipe
How do I write a PmWiki recipe? Is there a blueprint I can use? Are there any recipe examples?
Description
This recipe provides a simple recipe template that illustrates and implements some PmWiki recipe concepts.
The recipe provides a multiline directive with parameters that implements a printable and hexadecimal character display of all text within the directive. The form of such a directive is
(:directivename optional parameters:) optional lines of text (:directivenameend:)
.
It also provides a singleline directive that implements a display of some internal PmWiki variables. The form of such a directive is
(:directivename optional parameters:)
.
PmWiki Developers
This recipe illustrates some simple features of PmWiki recipes.
- \Markup (): markup, illustrating
(:directive parm=value:)
text(:directiveend:)
- \ParseArgs (): PmWiki function to create key value array from directive parameters
- \Keep (): PmWiki function to return HTML rather than wiki markup for page
- \SDV (): override default values from a configuration file
- $MessageFmt: log messages to the default PmWiki logging mechanism and displayed by the
(:messages:)
directive - $HTMLStylesFmt: insert CSS for the recipe into the page
- $HTMLHeaderFmt: insert into HTML metadata element
- dmsg: local function providing a way to debug a recipe
- $RecipeInfo: publish recipe version for PmWiki Site Analyzer and Recipe Check
- $FmtPV: create a page text variable enabling version display on a page
The recipe uses the following PHP features:
- Type hints
- Strict typing mode for argument and return values This assists with determining that the code behaves as expected
- Namespaces This assists with avoiding name collisions
Installation
- download
simplerecipetemplate-2022-06-11.phpΔ
- copy to the
/cookbook/
directory assimplerecipetemplate.php
- add to
config.php
the lineinclude_once(
$FarmD
/cookbook/simplerecipetemplate.php);
Usage
Place the directive, as described below, in your PmWiki page.
The recipe provides a page variable {$SimpleRecipeVersion}
which contains the current version, and page variable {$SimpleRecipe}
for a (:if enabled SimpleRecipe:)
recipe installation check.
Configuration
(:simplerecipe len=# :)
arbitrary text (:simplerecipeend:)
len=
-- number of characters to display per line, defaults to 16
Parameters are case-insensitive.
A second example is
(:verysimplerecipe:)
If no parameters are supplied this directive will display the directives it accepts.
You can use this recipe to display some internal PmWiki arrays.
These include:
$RecipeInfo
$Conditions
$CustomSyntax
,$FmtPV
$FmtV
$HandleActions
,$HandleAuth
$MarkupExpr
$HTMLStylesFmt
,$HTMLHeaderFmt
,$HTMLFooterFmt
PHPinfo
(requires admin login)$_SERVER
(requires admin login)
,$UploadExts
,$UploadExtSize
$UploadBlacklist
$WikiStyle
- a number of internal PmWiki variables including:
$Author
,$AuthorGroup
,$CategoryGroup
,$CookiePrefix
,$DefaultGroup
,$DefaultName
,$DefaultPage
,$GroupFooterFmt
,$GroupHeaderFmt
, $HandleImageTplFmt,$Skin
,$SiteAdminGroup
,$SiteGroup
,$UploadDir
,$UploadDirQuota
,$UploadMaxSize
,$UploadPrefixFmt
,$UploadPrefixQuota
,$UploadUrlFmt
,$Version
config.php
settings
You can change the following in config.php
. For example
$SimpleRecipeDebug = true; # results may vary
Change log / Release notes
2022-06-11 Addmore outputs, use PHSC 2022-04-24 Add some parameters to verysimplerecipe 2022-01-22 Initial version
See also
On PmWiki
From the PmWiki developer category:
- Complex Recipes Guidelines for people who want to share complex cookbook recipes with other PmWiki user
- Module Guidelines Guidelines for creating, distributing, and maintaining a recipe for the Cookbook.
- Debugging For Cookbook Authors Share tips and tricks with other authors about PmWiki specific debugging
Contributors
Special thanks to Petko and the PmWiki documenters.
Comments
See discussion at SimpleRecipeTemplate-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.