Andrea,

Thank you so much for your response! I was trying to use Geoserver's
"Publish Again" feature for my PostGIS layer and was not renaming the new
layer. This was throwing back an error. Now that I know I can republish the
same layer by renaming it, I'll be able to apply different FreeMarker
templates. Problem solved!

Thanks again!!
JD



On Wed, Apr 25, 2012 at 4:58 AM, Andrea Aime
<[email protected]>wrote:

> On Tue, Apr 24, 2012 at 10:53 PM, JD Godchaux <[email protected]> wrote:
>
>> Hello!
>>
>> I have a layer a PostGIS in Geoserver (2.1.3) with a FreeMarker template
>> (content.ftl) that resides in the type-specific Geoserver data directory -
>> in this case
>> /<geoserver_data_dir>/workspaces/<workspace>/<datastore>/<featuretype>/content.ftl.
>> This template works just fine in standard GetFeatureInfo requests.
>>
>> My problem comes when I want to use two different FreeMarker templates on
>> two different maps using the same Geoserver layer. I would like to have
>> different data and styles show up in the pop-ups for each map, and
>> currently, both maps are using the same FreeMarker template. Does anyone
>> know if what I'd like to do is possible in Geoserver?
>>
>> I've tried a few things so far, but without much success:
>>
>>    - I thought about publishing the same PostGIS layer twice in
>>    Geoserver, and this doens't appear to be possible. Geoserver will allow 
>> you
>>    to Publish Again," which overwrites previous configuration.
>>
>>
> Should not do that if you give it another name. With the same name it
> should give you an error though.
>
>
>>
>>    - The FreeMarker template seems to just deal with data returned from
>>    Geoserver and, since I'm making the same GetFeatureInfo request regardless
>>    of the map I'm using, the same data are returned. There didn't appear to 
>> be
>>    anything I could in the content.ftl file to show different templates on
>>    each map.
>>    - The WMSGetFeatureInfo request from OpenLayers doesn't seem to allow
>>    you to specify the map url as opposed to the standard WMS url.
>>
>> I'd be happy to provide more information on my specific situation if
>> needed, and thank you all for your help!!
>>
>
> Long story short, it's not possible to have different templates for the
> same layer, you'll have to publish
> the layer twice with two different names, and then add the templates in
> the two separate directories.
>
> Thinking about it, it should be possible to write code so that different
> templates are used for the
> same layer based on some vendor parameter, for example a way could be to
> specify a custom
> prefix in the request, &format_options=template_prefix:foo and have
> GeoServer look for
> foo_content.ftl instead of content.ftl. Of course this would need someone
> coding such new behavior.
>
> Cheers
> Andrea
>
> --
> -------------------------------------------------------
> Ing. Andrea Aime
> GeoSolutions S.A.S.
> Tech lead
>
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
>
> phone: +39 0584 962313
> fax:      +39 0584 962313
> mob:    +39 339 8844549
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.youtube.com/user/GeoSolutionsIT
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
> -------------------------------------------------------
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to