Query template variables

Richard Greenwood richard.greenwood at GMAIL.COM
Wed May 25 16:07:12 EDT 2005


Almudena Rueda <almudenarueda <at> INICIA.ES> writes:

> 
> Hi to all
> 
> I'm new on this stuff of Map server. I'm trying to make a template to take
> just some of the fields on a query as well as the fields on a join query
> but i can not understand the sintax to do that. I've try just putting the
> field name as it appears on the .dbf file but it doesn't work, the
> processquerytemplate() method doesn't 'translate' the var

Are you working in CGI or mapScript? Are you doing a one-to-one or a 
one-to-many join? For one-to-many in CGI you use the name of the join to
retreive the fields. Following are some notes from a thread on one-to-many joins
that might help:

Paul: The JOIN template is just about like any other query tempate except that
it can only contain replacement strings for the columns present in the joined
table. So, if dres010.dbf
contains the fields d_site_id, date and comments then the template:

  <li> Record [D_SITE_ID] ([DATE]): [COMMENTS]<br>

Will print a formatted line for each lab report for the well. The templates can
also contain javascript that might be used to build a collection of js objects
that could be used to do rudimentatry analysis, populate a graphing applet or
whatever. Join header and footers can be used to add opening and closing tag
sequences around a set of joined results. For example, to center the above
example use a header containing "<center>" and a footer containing "</center>".
In general join templates are real small (couple of bytes) files.

The main query template need to contain a substitution telling the server where
to place the multiple join results. So if you have a join called
"labjoin" then in
results.html you'd need a line:

[labjoin]

in the place where the results are supposed to go. Note the reference to the
join (i.e. [labjoin]) needs to sit by itself on a line due to the
complexity of the
replacement. Actually, any other code on the line will be lost so comments
would be ok.

Processing for an individual results QUERY goes like this.

1) QUERY template is processed
2) if [joinname] is found then the JOIN templates are processed: header,
template (multiple times), and finally the footer
3) processing continues on QUERY template

of course all of this can be sandwiched between LAYER header and footers, and
WEB header and footers to create
some very complex output.

Steve

<<< Paul Cedfeldt <pcedfeldt at crrel.usace.army.mil>  1/27  3:21p >>>
Hello,

I've been trying, with only partial success, to get a shapefile
connected to an external dbf with a one-to-many join.  When clicking on
a well on a map, I would like all lab records for that well (contained
in dres010.dbf) to display.  

The join works, but when a well is clicked the template results.html
only shows info for the last matching record from dres010 for that
well.  I imagine this has something to do with the join template
otmjoin.html, which should be processed once for each record according
to the docs, but otmjoin.html is currently empty since I'm not quite
sure what should be in there.

l 

-------h.map----------------

LAYER
  NAME well
  DESCRIPTION "Wells"
  TYPE point
  STATUS on
  DATA well
  TOLERANCE 5
  QUERY
    TEMPLATE results.html
    JOIN
      NAME labs
      TABLE /free/haines/d_res010.dbf
      FROM holp
      TO d_site_id
      TYPE multiple 
      TEMPLATE otmjoin.html
    END    
  END
END

------results.html---------

<HTML>
<body bgcolor=#FFFFFF>

Result [rn] <b
<p>
<br>Sample Num: [K_SAMPLE]
<br>Site AP Number: [D_SITE_ID]
<br>Lab Sample #: [K_LABSAMPI]
<br>
</HTML>

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com



More information about the mapserver-users mailing list