|
Cookbook /
RecipeInfoMarkupExpressionSummary: retrieve and print any property stored in $RecipeInfo, especially the current version of a specific recipe
Version: 2010-12-19
Prerequisites: none
Status:
Maintainer:
Categories: MarkupExpressions
Questions answered by this recipeHow can I display the current version of a recipe on a wiki page? DescriptionThis 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. (Other information about a recipe can also be stored in $RecipeInfo, though it seems these days to primarily be a repository for version...) NotesIf 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 {(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
See alsoContributorsCommentsUser 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. |