[mapserver-users] Multi template

Lime, Steve D (MNIT) steve.lime at state.mn.us
Thu Apr 27 15:57:18 PDT 2017


My suggestion is the same as before, use OUTPUTFORMATs. You can define a JSON format and a HTML format and process the same layer through both, including simple joins. The exception here is if you're doing one-to-many joins where the join itself requires a template. In that case you're stuck because there is no way to specify multiple templates for a one-to-many join. Wait! Actually you can, you just have to define the join multiple times, one for JSON and one for HTML - it's inefficient though.


The key here is that you're basically abandoning the TEMPLATE keyword at the layer level. Instead you do:


  OUTPUTFORMAT
    NAME 'json'
    DRIVER 'TEMPLATE'
    MIMETYPE 'application/json'
    FORMATOPTION "FILE=templates/json.tmpl"
    FORMATOPTION 'ATTACHMENT=mapserver.json'
  END


  OUTPUTFORMAT
    NAME 'html'
    DRIVER 'TEMPLATE'
    MIMETYPE 'text/html'
    FORMATOPTION "FILE=templates/html.tmpl"
    FORMATOPTION 'ATTACHMENT=mapserver.html'
  END


In your layer you'd have:


  TEMPLATE void


just to make the layer queryable.


If you're using the CGI you'd use queryformat=json or queryformat=html to switch between them. With WFS/WMS I believe you have to reference the mime type.


Please let me know if you have more questions. This can work well. I have several apps that return JSON, GEOJSON or HTML with a single layer.


Steve

________________________________
From: mapserver-users <mapserver-users-bounces at lists.osgeo.org> on behalf of pe_lord <pe_lord at yahoo.ca>
Sent: Thursday, April 27, 2017 6:48:13 AM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] Multi template

Any another hint to maintain 2 template on same layer?



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Multi-template-tp5317599p5318595.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20170427/ac9c075a/attachment.html>


More information about the mapserver-users mailing list