RecipeInfoMarkupExpression

Summary: retrieve and print any property stored in $RecipeInfo, especially the current version of a specific recipe
Version: 2010-12-19
Prerequisites: none
Status:
Maintainer:
Users: (View? / Edit?)
Categories: MarkupExpressions

Questions answered by this recipe

How can I display the current version of a recipe on a wiki page?

Description

This MarkupExpression makes it easy to retrieve and print the current version of a specific recipe installed on your wiki.

Most Cookbook recipes for PmWiki contain a declaration at the top filling the variable $RecipeInfo with the current version of a recipe.

    $RecipeInfo['RecipeName']['Version'] = 'NNNN-NN-NN';

(Other information about a recipe can also be stored in $RecipeInfo, though it seems these days to primarily be a repository for version...)

Notes

If you'd care to display the contents of $RecipeInfo for a specific recipe on your wiki, simply copy and paste the following code somewhere into your config.php. It does not need to be called before the actual recipe has been included.

{(RecipeInfo Version RecipeName)}

This version allows you to call any parameter possibly stored in $RecipeInfo, therefore it requires you to mention 'Version' when calling it:

# DISPLAY RECIPE INFO
## {(RecipeInfo Version RecipeName)}
## accesses $RecipeInfo['Recipe']['Version']
$MarkupExpr['RecipeInfo'] = 'RecipeInfoFunc($args)';
function RecipeInfoFunc($args) {
	global $RecipeInfo;
	$recipe = $args[1];
	$info = $args[0];
	return $RecipeInfo[$recipe][$info];
}

{(RecipeVersion RecipeName)}

This version only looks for the 'Version' stored in $RecipeInfo for a specific recipe:

# DISPLAY RECIPE VERSION
## Markup: {(RecipeVersion RecipeName)}
## accesses $RecipeInfo['Recipe']['Version']
$MarkupExpr['RecipeVersion'] = 'RecipeVersionFunc($args)';
function RecipeVersionFunc($args) {
	global $RecipeInfo;
	$recipe = $args[0];
	return $RecipeInfo[$recipe]['Version'];
}

Release notes

  • 2010-12-19

See also

Contributors

overtones99

Comments

This space is for User-contributed commentary and notes. Please include your name and a date (eg 2007-05-19) along with your comment. Optional alternative: create a new page with a name like "ThisRecipe-Talk" (e.g. PmCalendar-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.