acc149a45055759589098a1c6d723ecbd94e98c8
[yaffs-website] / topics / table.html
1 The 'table' formatter will convert an associative array into a formatted,
2 word-wrapped table.  Each item in the associative array represents one row
3 in the table.  Each row is similarly composed of associative arrays, with
4 the key of each item indicating the column, and the value indicating the
5 contents of the cell.  See below for an example source array.
6 <p>
7 The command core-requirements is an example of a command that produces output
8 in a tabular format.
9 <p>
10 <i>$ drush core-requirements</i>
11 <pre>
12  Title                 Severity  Description
13  Cron maintenance      Error     Last run 2 weeks ago
14  tasks                           Cron has not run recently. For more
15                                  information, see the online handbook entry for
16                                  configuring cron jobs. You can run cron
17                                  manually.
18  Drupal                Info      7.19
19 </pre>
20 (Note: the output above has been shortened for clarity; the actual output
21 of core-requirements contains additional rows not shown here.)
22 <p>
23 It is possible to determine the available fields by consulting <i>drush
24 help core requirements</i>:
25 <pre>
26  --fields=&lt;title, severity, description&gt;   Fields to output. All
27                                            available fields are:
28                                            title, severity, sid,
29                                            description, value,
30                                            reason, weight.
31 </pre>
32 It is possible to control the fields that appear in the table, and their
33 order, by naming the desired fields in the --fields option.  The space
34 between items is optional, so `--fields=title,sid` is valid.
35 <p>
36 Code:
37 <pre>
38 return array (
39   'cron' =>
40   array (
41     'title' => 'Cron maintenance tasks',
42     'severity' => 2,
43     'value' => 'Last run 2 weeks ago',
44     'description' => 'Cron has not run recently. For more information, see the online handbook entry for <a href="http://drupal.org/cron">configuring cron jobs</a>. You can <a href="/admin/reports/status/run-cron">run cron manually</a>.',
45     'severity-label' => 'Error',
46   ),
47   'drupal' =>
48   array (
49     'title' => 'Drupal',
50     'value' => '7.19',
51     'severity' => -1,
52     'weight' => -10,
53     'severity-label' => 'Info',
54   ),
55 )
56 </pre>