Take a look at this example in the implementation, open the map in Example 3 and cancel the header and footer in the city area layer. Save MapFile when done。
The HEADER
and FOOTER
object keywords within the layer are used to define the template keywords used in the header and footer templates.
You can uncomment the following two lines to see the template files themselves and see how they work.
HEADER '../templates/cities_header.html'
FOOTER '../templates/cities_footer.html'
Check the layer of "City" and click the "Refresh" button. The map will be refreshed and the city layer should now be displayed. Change the map mode to "Query Single Layer" or "Query Multiple Layers" and click on one of the cities.
The result should now have a heading and should be presented in tabular form
Here's what the cities_header.html looks like
<b>Layer: cities</b> <p> <table cellpadding=5 cellspacing=2 border=0> <tr bgcolor=#CCCCCC> <td bgcolor=#ffffff> </td> <th>NAME</th> <th>STATE</th> </tr>Here again is the content of cities_query.html file
<tr> <td>[lrn]</td> <td>[NAME]</td> <td>[STATE]</td> </tr>And finally, here's what the cities_footer.html looks like
</table> <p>
When MapServer processes the query for a particular layer, it first looks for a header template for that layer. It will then process the records that it gets back from the database, applying the query template for each record. When the template has been applied to all records, it will again look for the footer template for the layer. View the source of the query result page to see how this works
View the MapFile | View the HTML Template
7 | FONTSET "../fonts/fonts.list" | 7 | FONTSET "../fonts/fonts.list" | ||
n | 8 | TEMPLATEPATTERN "tmpl-*" | n | 8 | TEMPLATEPATTERN "example-p*" |
9 | LEGEND | 9 | LEGEND | ||
17 | END | 17 | END | ||
n | 18 | SYMBOL | n | ||
19 | NAME "star" | ||||
20 | TYPE VECTOR | ||||
21 | FILLED TRUE | ||||
22 | POINTS | ||||
23 | 0 0.375 | ||||
24 | 0.35 0.375 | ||||
25 | 0.5 0 | ||||
26 | 0.65 0.375 | ||||
27 | 1 0.375 | ||||
28 | 0.75 0.625 | ||||
29 | 0.875 1 | ||||
30 | 0.5 0.75 | ||||
31 | 0.125 1 | ||||
32 | 0.25 0.625 | ||||
33 | END | ||||
34 | END | ||||
35 | REFERENCE | 18 | REFERENCE | ||
36 | IMAGE "../images/worldref.png" | 19 | IMAGE "../images/worldref.png" | ||
n | 37 | SIZE 300 150 | n | 20 | SIZE 155 105 |
38 | EXTENT -180 -90 180 90 | 21 | EXTENT -180 -90 180 90 | ||
39 | STATUS ON | 22 | STATUS ON | ||
n | 40 | MINBOXSIZE 30 | n | 23 | MINBOXSIZE 10 |
41 | MAXBOXSIZE 150 | 24 | MAXBOXSIZE 150 | ||
n | 42 | COLOR 255 255 0 | n | 25 | COLOR -1 -1 -1 |
43 | OUTLINECOLOR 255 50 50 | 26 | OUTLINECOLOR 128 0 0 | ||
44 | MARKERSIZE 30 | 27 | MARKERSIZE 8 | ||
45 | MARKER "star" | 28 | MARKER "star" | ||
n | 46 | END | n | ||
47 | QUERYMAP | ||||
48 | SIZE 200 150 | ||||
49 | STATUS ON | ||||
50 | STYLE HILITE | ||||
51 | COLOR 255 0 0 | ||||
52 | END | 29 | END | ||
59 | STYLE 1 | 36 | STYLE 1 | ||
n | 60 | SIZE 160 2 | n | 37 | SIZE 100 2 |
61 | COLOR 0 0 0 | 38 | COLOR 0 0 0 | ||
n | 62 | UNITS KILOMETERS | n | 39 | UNITS MILES |
63 | INTERVALS 2 | 40 | INTERVALS 2 | ||
67 | WEB | 44 | WEB | ||
n | 68 | HEADER "qtpl_header.html" | n | ||
69 | FOOTER "qtpl_footer.html" | ||||
70 | TEMPLATE "to be replaced by map_web_template variable in section3.html" | 45 | TEMPLATE "to be replaced by map_web_template variable in section3.html" | ||
79 | LAYER | 54 | LAYER | ||
n | 80 | NAME "land" | n | 55 | NAME "topo" |
81 | DATA "land_shallow_topo_8192.tif" | 56 | DATA "land_shallow_topo_8192.tif" | ||
83 | TYPE RASTER | 58 | TYPE RASTER | ||
n | n | 59 | PROCESSING "BANDS=1,2,3" | ||
60 | OFFSITE 71 74 65 | ||||
84 | END | 61 | END | ||
85 | LAYER | 62 | LAYER | ||
n | 86 | NAME "topo" | n | 63 | NAME "modis_jpl" |
87 | TYPE RASTER | 64 | TYPE RASTER | ||
n | n | 65 | OFFSITE 0 0 0 | ||
66 | STATUS OFF | ||||
88 | CONNECTIONTYPE WMS | 67 | CONNECTIONTYPE WMS | ||
106 | LABELITEM "NAME" | 85 | LABELITEM "NAME" | ||
n | n | 86 | HEADER "../maptmpl/states_header.html" | ||
87 | FOOTER "../maptmpl/states_footer.html" | ||||
107 | TOLERANCE 3 | 88 | TOLERANCE 3 | ||
109 | NAME "the States" | 90 | NAME "the States" | ||
n | 110 | TEMPLATE "qtpl_country.html" | n | 91 | TEMPLATE "../maptmpl/states_query.html" |
111 | STYLE | 92 | STYLE | ||
131 | DATA "wriver.shp" | 112 | DATA "wriver.shp" | ||
n | 132 | STATUS ON | n | 113 | STATUS OFF |
133 | TYPE LINE | 114 | TYPE LINE | ||
n | 134 | TOLERANCE 3 | n | ||
135 | CLASS | 115 | CLASS | ||
136 | NAME "World River" | 116 | NAME "World River" | ||
t | 137 | TEMPLATE "qtpl_river.html" | t | ||
138 | STYLE | 117 | STYLE |