macroList 02 July 2013 / Updated: 19 January 2015
Note: The example macros in this text contain a space after the first and before the last bracket. This is to avoid them being executed. On real usages there should be none.
Macros are "delcared" by filters registered to the content_macro filter. The filter should add its macros to the array passed and return the result. A macro is defined by an array element. The index of the array element is the macro name.
Note: the plugin should be active both on THEMES to provide the function and on the ADMIN pages to provide the macro documentation.
The content of the array is as follows:
- "class" => macro class, see below.
- "params" => An array of parameter types. Append an * if the parameter may be omitted. The types allowed are:
- "string": may be enclosed in quotation marks when the macro is invoked. The quotes are stripped before the macro is processed.
- "int": a number
- "bool": true or false
- "array": will process assignment type parameter (x = y) lists. If the assignment is left out, the value will be inserted with its position in the list as the array index. Since an array parameter will consume all remaining elements it must be the last item in the parameter list.
- "value" => This is a function, procedure, expression or content as defined by the macro class.
- "owner" => This should be your plugin name.
- "desc" => Text that describes the macro usage.
- procedure Calls a script function that produces output. The output is captured and inserted in place of the macro instance.
- function Calls a script function that returns a result. The result is inserted in place of the macro instance.
- constant Replaces the macro instances with the constant provided.
- expression Evaluates the expression provided and replaces the instance with the result of the evaluation. If a regex is supplied for an expression. The values provided will replace placeholders in the expression. The first parameter replaces $1, the second $2, etc.
- [ CODEBLOCK 3 ] (Places codeblock number
3in your content)
- [ PAGE ] (Prints the current page number)
- [ ZENPHOTO_VERSION ] (Prints the version of the Zenphoto installation)
- [ PAGELINK mylinktext customscriptpage ] (Provides text for a link to a "custom" script page)
This extension is officially supported but not included in the ZenphotoCMS release.