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

Jean-Christophe Bastin jcbastin at thelis.be
Fri Jun 17 02:12:30 PDT 2022


Hello,

Thank you for the answer, but I already tried other extensions.
Even with « .html », the result is the same.
In fact, I can put anything in TEMPLATE, I always get the base results.

JCB

De : Kobben, Barend (UT-ITC) <b.j.kobben at utwente.nl>
Envoyé : vendredi 17 juin 2022 11:02
À : Jean-Christophe Bastin <jcbastin at thelis.be>; mapserver-users at lists.osgeo.org
Objet : Re: [mapserver-users] Need help/sample on how to use templating please

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/35211440/attachment.htm>


More information about the MapServer-users mailing list