[mapserver-users] Need help/sample on how to use templating please

Kobben, Barend (UT-ITC) b.j.kobben at utwente.nl
Fri Jun 17 02:02:12 PDT 2022


It might be as simple as naming the template template.html instead of template.tmpl....

--
Barend Köbben


On 17/06/2022, 10:50, "MapServer-users on behalf of Jean-Christophe Bastin" <mapserver-users-bounces at lists.osgeo.org<mailto:mapserver-users-bounces at lists.osgeo.org> on behalf of jcbastin at thelis.be<mailto:jcbastin at thelis.be>> wrote:

Hello community,

I try to find how to format click results of my MapFile.
I test my WMS on QGIS. By default, infotool result looks like this :

GetFeatureInfo results:
Layer 'my_layer'
  Feature 1234:
    field_1 = value_1
    field_2 = value_2
    field_3 = value_3
    …

The field names are base version coming from the data source.
I'm looking to change them in a more literal way, something like « My super field 1 has the great value 1 ».
I found that the way to reach this is templating.
I found the documentation :

  *   https://mapserver.org/mapfile/template.html#template
  *   https://mapserver.org/output/template_output.html?highlight=template
And I looked for examples but I can't make it work, I was wondering what I'm doing wrong.

Here is what I did :
I created a file "my_template.tmpl" containing just two lines :

<!-- MapServer Template -->
MY TEST

Then, in a working Mapfile, I added the TEMPLATE to my LAYER (the file "my_template.tmpl" is stored at the same level than my MapFile) :

MAP
     ...
     LAYER
          ...
          TEMPLATE "my_template.tmpl"
          ...
     END
END

If I understand well, when I click to get informations, I should see now "MY TEST" ?
But it continues to display the base informations like explained above.

I also tried with OUTPUTFORMAT, but it doesn't work better :

MAP
     OUTPUTFORMAT
          NAME "infotool_template"
          DRIVER "TEMPLATE"
          MIMETYPE "text/html"
          FORMATOPTION "FILE=my_template.tmpl"
     END
     ...
     LAYER
          ...
          TEMPLATE "infotool_template"
          ...
     END
END

I guess I do something wrong, but I can't find what.
Missing parameter ? Simple/double cotes issue ? Bad names/references ? Or something about the client (QGIS in my case) asking informations ?
Any help/advice will be very appreciated.
Hope to have some feedback.

Many thanks :-)

JCB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20220617/8e71503e/attachment-0001.htm>


More information about the MapServer-users mailing list