Recent Changes - Search:

add Cookbook page

hide Cookbook

Cookbook


hide Topics

Topics

show Changed

Changed

Visitor's book Site map pmwiki-2.3.37

Simple Recipe Template

To do
  • change skiwi
  • remove this comment

SimpleRecipe version 2024-01-01

Summary: A Simple Recipe Template to provide a framework for PmWiki recipes
Version: 2022-10-30
Prerequisites: PmWiki 2.3.2; PHP 7.4
Status: Always beta
Maintainer: skiwi
Licence: GPL3#
Users: (view / edit)

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:).

This is implemented as (:simplerecipe:) and described below.

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:).

This is implemented as (:pmwikiinfo:) and described below.

PmWiki Developers

This recipe illustrates some simple features of PmWiki recipes.

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

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.


SimpleRecipe output

Configuration

SimpleRecipe

(:simplerecipe len=# :) arbitrary text (:simplerecipeend:)

  • len= -- number of characters to display per line, defaults to 16

Parameters are case-insensitive.

PmWiki Info


PmWiki Info output (truncated)

A second example is (:pmwikiinfo:) If no parameters are supplied this directive will display the directives it accepts. You can use this recipe to display some internal PmWiki arrays and variables. These include:

and using

  • vars

a number of internal PmWiki variables including: $Author, $AuthorGroup, $CategoryGroup, $CookiePrefix, $DefaultGroup, $DefaultName, $DefaultPage, $GroupFooterFmt, $GroupHeaderFmt, $HandleImageTplFmt, $PageListSortComp, $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-10-30 Change very simple recipe to PmWikiInfo 2022-06-11 Add more outputs, use PHSC 2022-04-24 Add some parameters to PmWikiInfo 2022-01-22 Initial version

See also

On PmWiki

From the PmWiki developer category:

Contributors

Special thanks to Petko and the PmWiki documenters.

Comments

See discussion at SimpleRecipeTemplate-Talk

tahi Page last modified on 2022 Oct 25 10:47

Edit - History - Recent Changes - WikiHelp - Search - email page as link -> mailto:?Subject="KiwiWiki: Simple Recipe Template"&Body=