1 [[!template id=plugin name=field author="[[rubykat]]"]]
6 IkiWiki::Plugin::field - front-end for per-page record fields.
11 add_plugins => [qw{goodstuff field ....}],
14 field_register => [qw{meta}],
18 This plugin is meant to be used in conjunction with other plugins
19 in order to provide a uniform interface to access per-page structured
20 data, where each page is treated like a record, and the structured data
21 are fields in that record. This can include the meta-data for that page,
22 such as the page title.
24 Plugins can register a function which will return the value of a "field" for
25 a given page. This can be used in three ways:
27 * In page templates; all registered fields will be passed to the page template in the "pagetemplate" processing.
28 * In PageSpecs; the "field" function can be used to match the value of a field in a page.
29 * By other plugins, using the field_get_value function, to get the value of a field for a page, and do with it what they will.
33 The following options can be set in the ikiwiki setup file.
37 A list of plugin-IDs to register. This assumes that the plugins in
38 question store data in the %pagestatus hash using the ID of that plugin,
39 and thus the field values are looked for there.
41 This is the simplest form of registration, but the advantage is that it
42 doesn't require the plugin to be modified in order for it to be
43 registered with the "field" plugin.
47 The "field" PageSpec function can be used to match the value of a field for a page.
53 field(bar Foo*) will match if the "bar" field starts with "Foo".
59 field_register(id=>$id);
61 Register a plugin as having field data. The above form is the simplest, where the field value
62 is looked up in the %pagestatus hash under the plugin-id.
68 A reference to a function to call rather than just looking up the value in the %pagestatus hash.
69 It takes two arguments: the name of the field, and the name of the page. It is expected to return
70 the value of that field, or undef if there is no field by that name.
83 Set this to be called first in the sequence of calls looking for values. Since the first found
84 value is the one which is returned, ordering is significant.
88 Set this to be called last in the sequence of calls looking for values. Since the first found
89 value is the one which is returned, ordering is significant.
91 ### field_get_value($field, $page)
93 Returns the value of the field for that page, or undef if none is found.
97 * browse at GitHub: <http://github.com/rubykat/ikiplugins/blob/master/IkiWiki/Plugin/field.pm>
98 * git repo at git://github.com/rubykat/ikiplugins.git