[mapserver-users] Need help/sample on how to use templating please
Jean-Christophe Bastin
jcbastin at thelis.be
Fri Jun 17 01:50:11 PDT 2022
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/229bf8ac/attachment.htm>
More information about the MapServer-users
mailing list