RecipeInfoMarkupExpression
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
Comments
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.