macroList

    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:

    1. "class" => macro class, see below.
    2. "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.
    3. "value" => This is a function, procedure, expression or content as defined by the macro class.
    4. "owner" => This should be your plugin name.
    5. "desc" => Text that describes the macro usage.

    Macro classes:

    1. procedure Calls a script function that produces output. The output is captured and inserted in place of the macro instance.
    2. function Calls a script function that returns a result. The result is inserted in place of the macro instance.
    3. constant Replaces the macro instances with the constant provided.
    4. 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.

    Useage examples:

    1. [ CODEBLOCK 3 ] (Places codeblock number 3 in your content)
    2. [ PAGE ] (Prints the current page number)
    3. [ ZENPHOTO_VERSION ] (Prints the version of the Zenphoto installation)
    4. [ PAGELINK mylinktext customscriptpage ] (Provides text for a link to a "custom" script page)

     

    This extension is included in the ZenphotoCMS release.

    For questions and comments please use the forum or discuss on the social networks.


    More by author:

    Related items