To see this example in action, open example3.map and uncomment the
HEADER and FOOTER lines in the cities_poly layer. Save the mapfile when
you finish.
# The HEADER and FOOTER keywords within a layer object is used to define
# the header and footer templates for the TEMPLATE keyword used in the
# CLASS object. Uncomment the two lines below and look at the template
# files themselves to see how they work.
HEADER '../templates/cities_header.html'
FOOTER '../templates/cities_footer.html'
Check the "Cities" layer in the application and click on the "Refresh"
button. Now select "Query Single Layer" or "Query Multiple Layers" on
the "Map Mode" select box, 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
|