The Metadata Plugin
Metadata Management for Manila
 
Site last updated
2/24/2006; 12:33:21 PM
 
Home

Why

Features

FAQ

Updates

Documentation

Download

Developers

Bugs

Feedback

Discuss

Planned
Features

 
 

Page Macro

The page macro allows you to build a chunk of text using multiple metadata values in a single macro call. The format of the text is determined by a template message.

Syntax

page(templatemessageIdentifer, leadDelimiter = "[[", postDelimiter = "]]")

templateMessageIdentifier is the message number or shortcut name of the template message.

The template message is just like any other message in your Manila website which can be edited in the usual way.

The page macro builds its output by copying all text not between the start and stop delimiters and by expanding the text between the delimiters in the following way.

If the text is the name of a metadata variable (i.e., a meta type) it will be replaced with the value of the metadata variable in the current message.

If the text is the name of a metadata variable followed by the word shortcut, it will be replaced by the quoted value of the metadata variable in the current message. This is intended for storing shortcuts in metadata values

If the text is the name of a metadata variable followed by the word pictureRef, it will be replaced by a macro call to pictureRef with the shortcut parameter taking the value of the metadata variable in the current message. This is intended for storing shortcuts of pictures in metadata values.

If the text is the name of a metadata variable followed by the word foreach, followed by any text including text bracketed by matching lead and post delimiters, then it will be replaced by as many copies of the anytext as there are values of the metadata variable, with each copy of anytext appended after a string replace operation of #name# (name is the name of the metadata variable such as keywords). The page macro starts evaluation again at the beginning of the replacement text, so foreach constructs can be nested without limit. See "Multiboxes and foreach, a simple flat file database" for a more detailed example of how foreach can be used.

Most powerful of all, if the text is a legal macro identifier, it will be parsed looking for opportunities to replace the names of any metadata variables with their value from the current message. The resulting string must be a legal macro expression according to Manila. Not quite all valid macro expressions are handled, boolean expressions are not parsed, although simple arithmetic expressions and string concatenations are allowed.

After this process is complete, page calls html.processmacros to evaluate the shortcuts and macro calls that have been generated.

Examples:

Assuming metadata items called mdata1, mdata2

mdata1 {"value1"},
mdata2 {"value2a, value2b"}

a) [[mdata1]] - returns value1, that is the string value of mdata1

b) [[mdata1 shortcut]] - returns "value1" a quoted string for later expansion;

c) [[mdata1 pictureref]] - returns {pictureRef("value1")} for later expansion

d) [[any.legal.macro ()]] - returns -{any.legal.macro()} for later expansion (why bother?)

e) [[any.legal.macro (mdata1)]] - returns {any.legal.macro("value1")} for later expansion

f) [[any.legal.macro ("mdata1")]] - returns {any.legal.macro("mdata1")} - note difference quoting makes

g) [[any.legal.macro (p2:mdata2)]] - returns {any.legal.macro(p2:"value2a, value2b")}

h) [[any.legal.macro (mdata1, other.legal.macro(mdata2))]] - returns {any.legal.macro("value1", other.legalmacro("value2a, value2b"))}

i) [[any.legal.macro (p2:mdata1 + "xx")]] - returns {any.legal.macro(p2:"value1" + "xx")}

j) [[any.legal.macro (mdata1, 2 + other.legal.macro(mdata2))]] - returns {any.legal.macro("value1", 2 + other.legalmacro("value2a, value2b"))}

What's it for?

Well, my immediate need was to build different pages from the metadata of one message depending on the context. I also needed to be able to use macros whose parameters are metadata variables. I see this as a kind of report writer for metadata.

David Bayly

Comments...


This page last updated Wednesday, December 5, 2001 at 9:07:15 PM. (11245)