aboutsummaryrefslogtreecommitdiffstats
path: root/docs/html/cust-templates.html
blob: a7e33303024413951476193e748f373170ed2f59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
<HTML
><HEAD
><TITLE
>Template Customization</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="The Bugzilla Guide - 2.17.4 Development Release"
HREF="index.html"><LINK
REL="UP"
TITLE="Administering Bugzilla"
HREF="administration.html"><LINK
REL="PREVIOUS"
TITLE="Bugzilla Security"
HREF="security.html"><LINK
REL="NEXT"
TITLE="Change Permission Customization"
HREF="cust-change-permissions.html"></HEAD
><BODY
CLASS="section"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Bugzilla Guide - 2.17.4 Development Release</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="security.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 5. Administering Bugzilla</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="cust-change-permissions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="cust-templates"
></A
>5.7. Template Customization</H1
><P
>&#13;      One of the large changes for 2.16 was the templatization of the
      entire user-facing UI, using the 
      <A
HREF="http://www.template-toolkit.org"
TARGET="_top"
>Template Toolkit</A
>.
      Administrators can now configure the look and feel of Bugzilla without
      having to edit Perl files or face the nightmare of massive merge
      conflicts when they upgrade to a newer version in the future.
    </P
><P
>&#13;      Templatization also makes localized versions of Bugzilla possible, 
      for the first time. In the future, a Bugzilla installation may
      have templates installed for multiple localizations, and select
      which ones to use based on the user's browser language setting.      
    </P
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN1443"
></A
>5.7.1. What to Edit</H2
><P
>&#13;        There are two different ways of editing of Bugzilla's templates,
        and which you use depends mainly on how you upgrade Bugzilla. The
        template directory structure is that there's a top level directory,
        <TT
CLASS="filename"
>template</TT
>, which contains a directory for
        each installed localization. The default English templates are
        therefore in <TT
CLASS="filename"
>en</TT
>. Underneath that, there
        is the <TT
CLASS="filename"
>default</TT
> directory and optionally the 
        <TT
CLASS="filename"
>custom</TT
> directory. The <TT
CLASS="filename"
>default</TT
>
        directory contains all the templates shipped with Bugzilla, whereas
        the <TT
CLASS="filename"
>custom</TT
> directory does not exist at first and
        must be created if you want to use it.
      </P
><P
>&#13;        The first method of making customizations is to directly edit the
        templates in <TT
CLASS="filename"
>template/en/default</TT
>. This is
        probably the best method for small changes if you are going to use
        the CVS method of upgrading, because if you then execute a
        <B
CLASS="command"
>cvs update</B
>, any template fixes will get
        automagically merged into your modified versions.
      </P
><P
>&#13;        If you use this method, your installation will break if CVS conflicts
        occur.
      </P
><P
>&#13;        The other method is to copy the templates into a mirrored directory
        structure under <TT
CLASS="filename"
>template/en/custom</TT
>.  The templates
        in this directory automatically override those in default.  
        This is the technique you
        need to use if you use the overwriting method of upgrade, because
        otherwise your changes will be lost.  This method is also better if
        you are using the CVS method of upgrading and are going to make major
        changes, because it is guaranteed that the contents of this directory
        will not be touched during an upgrade, and you can then decide whether
        to continue using your own templates, or make the effort to merge your
        changes into the new versions by hand.
      </P
><P
>&#13;        If you use this method, your installation may break if incompatible
        changes are made to the template interface.  If such changes are made
        they will be documented in the release notes, provided you are using a
        stable release of Bugzilla.  If you use using unstable code, you will
        need to deal with this one yourself, although if possible the changes
        will be mentioned before they occur in the deprecations section of the
        previous stable release's release notes.
      </P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>&#13;          Don't directly edit the compiled templates in 
          <TT
CLASS="filename"
>data/template/*</TT
> - your
          changes will be lost when Template Toolkit recompiles them.
        </P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN1462"
></A
>5.7.2. How To Edit Templates</H2
><P
>&#13;        The syntax of the Template Toolkit language is beyond the scope of
        this guide. It's reasonably easy to pick up by looking at the current 
        templates; or, you can read the manual, available on the
        <A
HREF="http://www.template-toolkit.org"
TARGET="_top"
>Template Toolkit home
        page</A
>. However, you should particularly remember (for security
        reasons) to always HTML filter things which come from the database or
        user input, to prevent cross-site scripting attacks.
      </P
><P
>&#13;        However, one thing you should take particular care about is the need
        to properly HTML filter data that has been passed into the template.
        This means that if the data can possibly contain special HTML characters
        such as &#60;, and the data was not intended to be HTML, they need to be
        converted to entity form, ie &#38;lt;.  You use the 'html' filter in the
        Template Toolkit to do this.  If you fail to do this, you may open up
        your installation to cross-site scripting attacks.
      </P
><P
>&#13;        Also note that Bugzilla adds a few filters of its own, that are not
        in standard Template Toolkit.  In particular, the 'url_quote' filter
        can convert characters that are illegal or have special meaning in URLs,
        such as &#38;, to the encoded form, ie %26.  This actually encodes most
        characters (but not the common ones such as letters and numbers and so
        on), including the HTML-special characters, so there's never a need to
        HTML filter afterwards.
      </P
><P
>&#13;        Editing templates is a good way of doing a "poor man's custom fields".
        For example, if you don't use the Status Whiteboard, but want to have
        a free-form text entry box for "Build Identifier", then you can just
        edit the templates to change the field labels. It's still be called
        status_whiteboard internally, but your users don't need to know that.
      </P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>&#13;          If you are making template changes that you intend on submitting back
          for inclusion in standard Bugzilla, you should read the relevant
          sections of the 
          <A
HREF="http://www.bugzilla.org/developerguide.html"
TARGET="_top"
>Developers'
          Guide</A
>.
        </P
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN1472"
></A
>5.7.3. Template Formats</H2
><P
>&#13;        Some CGIs have the ability to use more than one template. For
        example, buglist.cgi can output bug lists as RDF or two
        different forms of HTML (complex and simple). (Try this out
        by appending <TT
CLASS="filename"
>&#38;format=simple</TT
> to a buglist.cgi
        URL on your Bugzilla installation.) This
        mechanism, called template 'formats', is extensible.
      </P
><P
>&#13;        To see if a CGI supports multiple output formats, grep the
        CGI for "ValidateOutputFormat". If it's not present, adding
        multiple format support isn't too hard - see how it's done in
        other CGIs.
      </P
><P
>&#13;        To make a new format template for a CGI which supports this, 
        open a current template for
        that CGI and take note of the INTERFACE comment (if present.) This 
        comment defines what variables are passed into this template. If 
        there isn't one, I'm afraid you'll have to read the template and
        the code to find out what information you get. 
      </P
><P
>&#13;        Write your template in whatever markup or text style is appropriate.
      </P
><P
>&#13;        You now need to decide what content type you want your template
        served as. Open up the <TT
CLASS="filename"
>localconfig</TT
> file and find the 
        <TT
CLASS="filename"
>$contenttypes</TT
>
        variable. If your content type is not there, add it. Remember
        the three- or four-letter tag assigned to you content type. 
        This tag will be part of the template filename.
      </P
><P
>&#13;        Save the template as <TT
CLASS="filename"
>&#60;stubname&#62;-&#60;formatname&#62;.&#60;contenttypetag&#62;.tmpl</TT
>. 
        Try out the template by calling the CGI as 
        <TT
CLASS="filename"
>&#60;cginame&#62;.cgi?format=&#60;formatname&#62;</TT
> .
      </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="AEN1485"
></A
>5.7.4. Particular Templates</H2
><P
>&#13;        There are a few templates you may be particularly interested in
        customizing for your installation.
      </P
><P
>&#13;        <B
CLASS="command"
>index.html.tmpl</B
>:
        This is the Bugzilla front page.
      </P
><P
>&#13;        <B
CLASS="command"
>global/header.html.tmpl</B
>:
        This defines the header that goes on all Bugzilla pages.
        The header includes the banner, which is what appears to users
        and is probably what you want to edit instead.  However the
        header also includes the HTML HEAD section, so you could for
        example add a stylesheet or META tag by editing the header.
      </P
><P
>&#13;        <B
CLASS="command"
>global/banner.html.tmpl</B
>:
        This contains the "banner", the part of the header that appears
        at the top of all Bugzilla pages.  The default banner is reasonably
        barren, so you'll probably want to customize this to give your
        installation a distinctive look and feel.  It is recommended you
        preserve the Bugzilla version number in some form so the version 
        you are running can be determined, and users know what docs to read.
      </P
><P
>&#13;        <B
CLASS="command"
>global/footer.html.tmpl</B
>:
        This defines the footer that goes on all Bugzilla pages.  Editing
        this is another way to quickly get a distinctive look and feel for
        your Bugzilla installation.
      </P
><P
>&#13;        <B
CLASS="command"
>bug/create/user-message.html.tmpl</B
>:
        This is a message that appears near the top of the bug reporting page.
        By modifying this, you can tell your users how they should report
        bugs.
      </P
><P
>&#13;        <B
CLASS="command"
>bug/process/midair.html.tmpl</B
>:
        This is the page used if two people submit simultaneous changes to the
        same bug.  The second person to submit their changes will get this page
        to tell them what the first person did, and ask if they wish to
        overwrite those changes or go back and revisit the bug.  The default
        title and header on this page read "Mid-air collision detected!"  If
        you work in the aviation industry, or other environment where this
        might be found offensive (yes, we have true stories of this happening)
        you'll want to change this to something more appropriate for your
        environment.
      </P
><P
>&#13;        <B
CLASS="command"
>bug/create/create.html.tmpl</B
> and
        <B
CLASS="command"
>bug/create/comment.txt.tmpl</B
>:
        You may wish to get bug submitters to give certain bits of structured
        information, each in a separate input widget, for which there is not a
        field in the database. The bug entry system has been designed in an
        extensible fashion to enable you to define arbitrary fields and widgets,
        and have their values appear formatted in the initial
        Description, rather than in database fields. An example of this
        is the mozilla.org 
        <A
HREF="http://bugzilla.mozilla.org/enter_bug.cgi?format=guided"
TARGET="_top"
>guided 
        bug submission form</A
>.
      </P
><P
>&#13;        To make this work, create a custom template for 
        <TT
CLASS="filename"
>enter_bug.cgi</TT
> (the default template, on which you
        could base it, is <TT
CLASS="filename"
>create.html.tmpl</TT
>),
        and either call it <TT
CLASS="filename"
>create.html.tmpl</TT
> or use a format and
        call it <TT
CLASS="filename"
>create-&#60;formatname&#62;.html.tmpl</TT
>.
        Put it in the <TT
CLASS="filename"
>custom/bug/create</TT
>
        directory. In it, add widgets for each piece of information you'd like
        collected - such as a build number, or set of steps to reproduce.
      </P
><P
>&#13;        Then, create a template like 
        <TT
CLASS="filename"
>custom/bug/create/comment.txt.tmpl</TT
>, also named
        after your format if you are using one, which
        references the form fields you have created. When a bug report is
        submitted, the initial comment attached to the bug report will be
        formatted according to the layout of this template.
      </P
><P
>&#13;        For example, if your enter_bug template had a field
        <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#60;input type="text" name="buildid" size="30"&#62;</PRE
></FONT
></TD
></TR
></TABLE
>
        and then your comment.txt.tmpl had
        <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>BuildID: [% form.buildid %]</PRE
></FONT
></TD
></TR
></TABLE
>
        then
        <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>BuildID: 20020303</PRE
></FONT
></TD
></TR
></TABLE
>
        would appear in the initial checkin comment.
      </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="security.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="cust-change-permissions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Bugzilla Security</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="administration.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Change Permission Customization</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>