]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/plugins/contrib/report/ikiwiki/directive/report.mdwn
df88b33adbba06bbde3425884e9af45067a68090
[git.ikiwiki.info.git] / doc / plugins / contrib / report / ikiwiki / directive / report.mdwn
1 [[!toc]]
2 The `report` directive is supplied by the [[!iki plugins/contrib/report desc=report]] plugin.
4 This enables one to report on the structured data ("field" values) of
5 multiple pages; the output is formatted via a template.  This depends
6 on the [[plugins/contrib/field]] plugin.
8 The pages to report on are selected by a PageSpec given by the "pages"
9 parameter.  The template is given by the "template" parameter.
10 The template expects the data from a single page; it is applied
11 to each matching page separately, one after the other.
13 Additional parameters can be used to fill out the template, in
14 addition to the "field" values.  Passed-in values override the
15 "field" values.
17 There are two places where template files can live.  One is in the
18 /templates directory on the wiki.  These templates are wiki pages, and
19 can be edited from the web like other wiki pages.
21 The second place where template files can live is in the global
22 templates directory (the same place where the page.tmpl template lives).
23 This is a useful place to put template files if you want to prevent
24 them being edited from the web, and you don't want to have to make
25 them work as wiki pages.
27 ## OPTIONS
29 **template**: The template to use for the report.
31 **pages**: A PageSpec to determine the pages to report on.
33 **pagenames**: If given instead of pages, this is interpreted as a
34 space-separated list of links to pages, and they are shown in exactly the order
35 given: the sort and pages parameters cannot be used in conjunction with this
36 one.  If they are used, they will be ignored.
38 **trail**: A page or pages to use as a "trail" page.
40 When a trail page is used, the matching pages are limited to (a subset
41 of) the pages which that page links to; the "pages" pagespec in this
42 case, rather than selecting pages from the entire wiki, will select
43 pages from within the set of pages given by the trail page.
45 Additional space-separated trail pages can be given in this option.
46 For example:
48     trail="animals/cats animals/dogs"
50 This will take the links from both the "animals/cats" page and the
51 "animals/dogs" page as the set of pages to apply the PageSpec to.
53 **start**: Start the report at the given page-index; the index starts
54 from zero.
56 **count**: Report only on N pages where count=N.
58 **sort**: A SortSpec to determine how the matching pages should be sorted.
60 **here_only**: Report on the current page only.
62 This is useful in combination with "prev_" and "next_" variables to
63 make a navigation trail.
64 If the current page doesn't match the pagespec, then no pages will
65 be reported on.
67 ### Headers
69 An additional option is the "headers" option.  This is a space-separated
70 list of field names which are to be used as headers in the report.  This
71 is a way of getting around one of the limitations of HTML::Template, that
72 is, not being able to do tests such as
73 "if this-header is not equal to previous-header".
75 Instead, that logic is performed inside the plugin.  The template is
76 given parameters "HEADER1", "HEADER2" and so on, for each header.
77 If the value of a header field is the same as the previous value,
78 then HEADER**N** is set to be empty, but if the value of the header
79 field is new, then HEADER**N** is given that value.
81 #### Example
83 Suppose you're writing a blog in which you record "moods", and you
84 want to display your blog posts by mood.
86     \[[!report template="mood_summary"
87     pages="blog/*"
88     sort="Mood Date title"
89     headers="Mood"]]
91 The "mood_summary" template might be like this:
93     <TMPL_IF NAME="HEADER1">
94     ## <TMPL_VAR NAME="HEADER1">
95     </TMPL_IF>
96     ### <TMPL_VAR NAME="TITLE">
97     (<TMPL_VAR NAME="DATE">) \[[<TMPL_VAR NAME="PAGE">]]
98     <TMPL_VAR NAME="DESCRIPTION">
99  
100 ### Multi-page Reports
102 Reports can now be split over multiple pages, so that there aren't
103 too many items per report-page.
105 **per_page**: how many items to show per report-page.
107 **first_page_is_index**: If true, the first page of the report is just
108 an index which contains links to the other report pages.
109 If false, the first page will contain report-content as well as links
110 to the other pages.
112 ### Advanced Options
114 The following options are used to improve efficiency when dealing
115 with large numbers of pages; most people probably won't need them.
117 **doscan**:
119 Whether this report should be called in "scan" mode; if it is, then
120 the pages which match the pagespec are added to the list of links from
121 this page.  This can be used by *another* report by setting this
122 page to be a "trail" page in *that* report.
123 It is not possible to use "trail" and "doscan" at the same time.
124 By default, "doscan" is false.
126 ## TEMPLATE PARAMETERS
128 The templates are in HTML::Template format, just as [[plugins/template]] and
129 [[ftemplate]] are.  The parameters passed in to the template are as follows:
131 ### Fields
133 The structured data from the current matching page.  This includes
134 "title" and "description" if they are defined.
136 ### Common values
138 Values known for all pages: "page", "destpage".  Also "basename" (the
139 base name of the page).
141 ### Passed-in values
143 Any additional parameters to the report directive are passed to the
144 template; a parameter will override the matching "field" value.
145 For example, if you have a "Mood" field, and you pass Mood="bad" to
146 the report, then that will be the Mood which is given for the whole
147 report.
149 Generally this is useful if one wishes to make a more generic
150 template and hide or show portions of it depending on what
151 values are passed in the report directive call.
153 For example, one could have a "hide_mood" parameter which would hide
154 the "Mood" section of your template when it is true, which one could
155 use when the Mood is one of the headers.
157 ### Prev_ And Next_ Items
159 Any of the above variables can be prefixed with "prev_" or "next_"
160 and that will give the previous or next value of that variable; that is,
161 the value from the previous or next page that this report is reporting on.
162 This is mainly useful for a "here_only" report.
164 ### Headers
166 See the section on Headers.
168 ### First and Last
170 If this is the first page-record in the report, then "first" is true.
171 If this is the last page-record in the report, then "last" is true.