Cookbook /
MarkupExpressionsExtensions
Summary: 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: (unsupported since 2008)
Discussion: MarkupExpressionsExtensions-Talk
Questions answered by this recipe
Questions:
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?
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.
{(count Group)} | Number of pages in current group, or if specified another group. Use a | to begin a list of CSV excluded page names. |
{(thread Group)} | Thread for current group, or if specified another group. Highest number page in the group +1 |
{$Captcha} | Random number between 10000 and 99999, all after instances on same page return the same number. Add two numbers if you want to change the range. |
{(math '(2+3) * 7 /4')} | Returns 8.75. Can take any basic math expression. Accepted characters configurable |
{(wiki pagelist group=Main)} | Changes to (:pagelist group=Main:) and executes. Can be stored in a hidden text variable. Default allowed directives include: table, tableend, cell, cellnr, include, if, pagelist, input, messages, redirect, title. Can also be configured to include ZAP forms. |
{(source Group.Name#ID123)} | Returns source code for that page, and that section if specified. Use the included (:textarea:) markup to prefill the source into a textarea. Put a + before Group.Name to eliminate trailing textarea. |
{$IPAddress} | Returns ip address of visitor. Other var's available include $ReturnLink (referrer link), $Browser, and $DomainName. |
{(list '{$:mylist}' '[[~{item}]]^[[<<]]')} | Converts the CSV text var mylist into a nicely formatted list of links to their profile pages. Can be configured however you want. |
{$Keywords} | Returns keywords for a page (to match $Title & $Description) and if authorized, the $PasswdEdit, $PasswdRead attributes for current page. Add a pagename parameter to return the attributes of a different page. |
{(random 1 6)} | Returns a random number between 1 and 6 |
{$Now} | Returns current unix timestamp. |
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
- Caveman Click here to learn more about the story behind this recipe...
- Many others who have suggested countless ideas along the way.
Comments
See Discussion at MarkupExpressionsExtensions-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.