|
Cookbook /
MarkupExpressionsExtensionsSummary: Adds math, threads, captcha, group counter, random number, attr reader, CSV formatter, server variables, source reader, etc.
Version: 2007-04-19
Prerequisites: Very latest version of PmWiki beta series or Pm's MarkupExpression recipe.
Status: Stable
Maintainer:
Questions answered by this recipeQuestions:
How can I do basic math calculations on a wiki page? How can I add basic captcha capabilities to my wiki? How can I tell how many pages there are in a group? How can I get a thread number for some group? How can I display a CSV list, nicely formatted? How can I show markup from a page or section of a page? How can I get server variable information from a visitor? Answer:
Download and enable the mkexpext module: mkexpext.phpΔ
Note: Feel free to delete functions you don't want or just borrow one or two and add to a config page for a special need. Also note, these markups are all included in Acme's ZAP Toolbox. Do not use this recipe if you have that installed.
How it works:Below are some of the extensions (and some page variables) that are available to you if you install this recipe.
There may be some other things I left out... As the markup expressions are all processed just after page and text variables, page and text variables can be used in them. Because it is processed just before conditionals and other directives, it can be used in them. Also, MarkupExpressions allow for nice chaining of these functions! Have fun... Note: just fixed a bug in the wiki expression extension and fixed the authorization line in the source expression. 4/19/2007 Caveman
Contributors
CommentsQuestions by HansB: The count markup gives different results than Pm's pagelist fmt=count (PagelistCount). It may be because this recipe uses a hardcoded exclusion list, and so will not reflect custom exclusion lists as PmWiki allows. In any case Pagelistcount is more flexible and more accurate, so i am not sure why {(count)} is needed.
I am not sure what "Thread" means. Last page in a group of pages with numeric page names?
Why is the {(pagelist group=Group)} markup needed, if all it does is to translate the normal syntax?
For some of these markups I wonder why the normal pmwiki pagevariable syntax
Here's another useful one: ##(str_replace) markup expression
SDV($MarkupExpr['str_replace'], 'str_replace(explode(",",$args[0]), explode(",",$args[1]), $args[2])');
So given the page text variable (:text: You can't chew pizza all day.:) The markup expression {(str_replace "pizza" "ooba" "{$:text}")}
returns the string You can't chew ooba all day. And the more complex expression {(str_replace "chew","pizza","day" "eat","ooba","night" "{$:text}")}
performs multiple replacements and produces You can't eat ooba all night. You can also replace an array with a string, allowing you to strip various unwanted characters (or words) from a variable: (:myname: Mary O'Meara-Malloy:)
{(str_replace " ","'","-" "" {$:myname})}
produces MaryOMearaMalloy Ben Stallings May 28, 2007, at 10:47 AM I like the functionality this recipe offers. Unfortunately for me it caused action=attr to show incorrect settings (the worst case: one page's read authorizations appeared for other pages to which they did not apply). When I removed the recipe, the authorizations appeared correctly again. - RandyB January 27, 2008 at 7:22 PM as function ereg is deprecated in php 5.3.0 . - KPX? April 26, 2011, at 09:53 PM 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. |