There are two templating options in MapServer 5.2+. The first is the "classic" method that uses a series of small template files to construct a result set. I believe it's like so:
1. web header ... for each layer 2. layer header ... for each feature in the layer 3. layer or class template 4. layer footer 5. web footer In 5.2 there's a new option to use new template tags in combination with a new output format. (see http://mapserver.org/development/rfc/ms-rfc-36.html). Here's an example: The output format block: OUTPUTFORMAT NAME 'county_select_list' DRIVER 'TEMPLATE' MIMETYPE 'text/javascript' FORMATOPTION 'ATTACHMENT=county_select_list.js' FORMATOPTION 'FILE=/templates/county_select_list.js' END The template (county_select_list.js): function updateCountyList(element) { var option; [resultset layer="counties"][feature] option = new Option("[CTY_NAME]", "[shpext format="$minx,$miny,$maxx,$maxy" precision=0 expand="10%"]"); try { element.add(option, null); } catch(e) { element.add(option); } [/feature][/resultset] } The tags to pay attention to are [resultset] and [feature]. The [resultset] tag is used to present a layer, the [feature] tag is used to present 1 feature. So, in the above example if the layer "counties" has results then we'll process the code between the [resultset][/resultset] block. And the for each feature in the layer we process the code between the [feature][/feature] block. Works nice. You can choose which output format to use with the qformat CGI variable. Here's the output generated through this template: function updateCountyList(element) { var option; option = new Option("Clearwater", "304963,5219538,337550,5326697"); try { element.add(option, null); } catch(e) { element.add(option); } option = new Option("Aitkin", "434591,5106383,498803,5213702"); try { element.add(option, null); } catch(e) { element.add(option); } option = new Option("Chisago", "486969,5013450,529584,5066587"); try { element.add(option, null); } catch(e) { element.add(option); } option = new Option("Blue Earth", "387528,4852924,441106,4904495"); try { element.add(option, null); } catch(e) { element.add(option); } } You certainly can have multiple layers in one template of this form. Hope this helps. Steve >>> On 2/24/2009 at 7:30 PM, in message <[email protected]>, Greg Luker <[email protected]> wrote: > Hi mapserver-users, > > How does nquery templating work? > I'm trying to modify nquery result contents using javascript (I don't > know much about javascript!). The best I have done so far is (nquery > template): > > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > </head> > <body> > <script language="Javascript" type="text/javascript"> > var Cell = window.document.all.A1; > Cell.innerText = " "; > </script> > <form name="table1" method="post"> > <tr bgcolor=#FFFFD0> > <td ID="A1">[site_code]</td> > <td>[site_name]</td> > <td>[featdesc_description]</td> > <td>[feature_comment]</td> > <td>[genderaccess_description]</td> > </tr> > </form> > </body> > </html> > > Which blanks the first [site_code] returned, but I want to blank > repeating [site_code] in the nquery result table. Any ideas > gratefully accepted! > > Thanks, > Greg. > > > Greg Luker > GIS Lab Manager, Southern Cross University > Lismore, AUSTRALIA. > [email protected] > phone 61 2 66203026 > > > > _______________________________________________ > mapserver-users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/mapserver-users _______________________________________________ mapserver-users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/mapserver-users
