<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 10pt">
<DIV>Unless you have some crazy old version of Geoserver, you do NOT need to
create a template on the server side. Just make the infoformat parameter “JSON”
to get back GeoJSON rather than text/html.</DIV>
<DIV>I’ve accomplished what you are trying to do on several projects. Keep in
mind that the GeoExt popup inherits from Ext.Window so you should configure the
contents just as you would for that.</DIV>
<DIV> </DIV>
<DIV>What I do is:</DIV>
<DIV>1. create XTemplates, either in hidden markup or in a separate js
file</DIV>
<DIV>2. key the templates by the featureType (either as the div id or as a
javascript object key) </DIV>
<DIV>3. apply the appropriate template for each feature returned</DIV>
<DIV>4. create a GeoExt popup with the HTML created in step 3 inserted in the
correct place</DIV>
<DIV> </DIV>
<DIV>So your GFI handler would be something like this:</DIV>
<DIV> </DIV>
<DIV><FONT style="FONT-SIZE: 9.8pt">> getfeatureinfo: function(e)
{<BR>if(e.features && e.features.length){</FONT></DIV>
<DIV>var results = {};</DIV>
<DIV>//Loop through the different features, apply templates, and store results
in a featureType keyed object</DIV>
<DIV>Ext.each(e.features,function(feat){</DIV>
<DIV> var type = feat.fid.split(‘.’)[0];</DIV>
<DIV> if(!results[type]){results[type]=[]}</DIV>
<DIV>
results[type].push(MyTemplates[type].apply(feat.attributes));</DIV>
<DIV>});</DIV>
<DIV>var popItems = [];</DIV>
<DIV>//Loop through returned featureTypes and create a panel for each one to put
into the </DIV>
<DIV>//popup’s accordion layout</DIV>
<DIV>Ext.iterate(results,function(ftype,vals){</DIV>
<DIV> var panel = {</DIV>
<DIV> title:ftype,</DIV>
<DIV>
html:’<div>’+vals.join(‘</div><div>’)+’</div>’,</DIV>
<DIV> width:400}</DIV>
<DIV> popItems.push(panel)</DIV>
<DIV>});</DIV>
<DIV><FONT style="FONT-SIZE: 9.8pt">> new GeoExt.Popup({<BR>> title:
"Position:<BR>> "+mappanel.map.getLonLatFromPixel(e.xy).transform(epsg900913,
epsg4326),<BR>> width: 400,<BR>> autoHeight: true,<BR>> layout:
'accordion',<BR>> bodyStyle:
'background-color:#FFF;,font-size:14px;',<BR>> autoScroll: true,<BR>>
maximizable: true,<BR>> map: mappanel.map,<BR>> lonlat:
mappanel.map.getLonLatFromPixel(e.xy),<BR>> unpinnable:true,<BR>>
anchored: true,<BR>> shadow: true,<BR><FONT
size=2>items:popItems,</FONT></FONT></DIV>
<DIV><FONT style="FONT-SIZE: 9.8pt">> listeners: {<BR>> close: function()
{<BR>> // closing a popup destroys it, but our reference<BR>> is<BR>>
truthy<BR>> popup = null;<BR>> }<BR>> }<BR>> }).show();<BR>>
}</FONT><BR></DIV>
<DIV>I wrote this on the fly, so beware of typos and not quite complete logic,
but that should at least get you started on the right path</DIV>
<DIV> </DIV>
<DIV>Matt Priour</DIV>
<DIV>Kestrel Computer Consulting</DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV><FONT face=Arial></FONT> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=hfpmartins@gmail.com
href="mailto:hfpmartins@gmail.com">Hugo</A> </DIV>
<DIV><B>Sent:</B> Thursday, July 21, 2011 6:19 AM</DIV>
<DIV><B>To:</B> <A title=robertdbuckley@yahoo.com
href="mailto:robertdbuckley@yahoo.com">Robert Buckley</A> </DIV>
<DIV><B>Cc:</B> <A title=users@geoext.org
href="mailto:users@geoext.org">users@geoext.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Users] control which fields are displayed in my Geoext
popups</DIV></DIV></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">Hi
Robert,
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>What you can do in fact is:</DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>- Make a geoserver template that will return your data in JSON format</DIV>
<DIV>- Then, process the data as you wish on the client side (this is, using
GeoExt)</DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>Below you can find an example of content.ftl that is returning the data in
JSON format.</DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>
<DIV>[{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#assign i =
0 /></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#list
type.attributes as attribute></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#if (i >=
0) && (!attribute.isGeometry)></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>"${<A
href="http://attribute.name">attribute.name</A>}":</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#list
features as feature></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#assign k =
0 /></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#list
feature.attributes as attribute></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#if (k = i)
&& (!attribute.isGeometry)></DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN>"${attribute.value}"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN></#if></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#assign k =
k+1 /></DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN></#list></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#if
attribute_has_next></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>,</DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN></#if></DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN></#list></DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN></#if></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN><#assign i =
i+1 /></DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN></#list></DIV>
<DIV>}]</DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>hope this helps.</DIV>
<DIV>Cheers,</DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>Hugo</DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV class=gmail_quote>On Thu, Jul 21, 2011 at 12:15 PM, Robert Buckley <SPAN
dir=ltr><<A
href="mailto:robertdbuckley@yahoo.com">robertdbuckley@yahoo.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 10pt">
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><CODE>Hi,</CODE></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><CODE><BR></CODE></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><CODE>Standard
format... </CODE><SPAN style="FONT-FAMILY: monospace">text/html as defined in
the Parameter tab in Firebug.</SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace"><BR></SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace">I have read that if the format is changed, then
the attributes can be manipulated ie fields can be left out. I haven´t seen
any code fór it though.</SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace"><BR></SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace">I have tried with the content.ftl file in the
geoserver workspaces, but the results are pretty grim! I would rather do it in
javascript so that everything is kept in my app and not spread around
different applications.</SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace"><BR></SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace">yours,</SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace"><BR></SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace">Rob</SPAN></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace"><BR></SPAN></DIV>
<DIV class=hm>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif"><SPAN
style="FONT-FAMILY: monospace"><BR></SPAN></DIV></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 10pt">
<DIV class=hm> </DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 13px">
<DIV class=hm><FONT size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">Von:</SPAN></B> "<A
href="mailto:dan@inlet.geol.sc.edu" target=_blank>dan@inlet.geol.sc.edu</A>"
<<A href="mailto:dan@inlet.geol.sc.edu"
target=_blank>dan@inlet.geol.sc.edu</A>><BR><B><SPAN
style="FONT-WEIGHT: bold">An:</SPAN></B> Robert Buckley <<A
href="mailto:robertdbuckley@yahoo.com"
target=_blank>robertdbuckley@yahoo.com</A>><BR><B><SPAN
style="FONT-WEIGHT: bold">CC:</SPAN></B> <A href="mailto:users@geoext.org"
target=_blank>users@geoext.org</A><BR><B><SPAN
style="FONT-WEIGHT: bold">Gesendet:</SPAN></B> Donnerstag, den 21. Juli 2011,
12:24:24 Uhr<BR><B><SPAN style="FONT-WEIGHT: bold">Betreff:</SPAN></B> Re:
[Users] control which fields are displayed in my Geoext
popups<BR></FONT></DIV>
<DIV>
<DIV></DIV>
<DIV class=h5><FONT size=2></FONT><BR>What is the format of the data coming
back from the WMSGetFeatureInfo?<BR><BR>> Hi,<BR>><BR>> I would like
to do the following and after several hours of trying and<BR>>
googling<BR>> will have to admit that I haven´t got far.<BR>><BR>> I
want to ...<BR>><BR>> 1. Restrict the fields displayed in my popup
window so that I can control<BR>> which<BR>> fields are displayed. I
don´t want to show fid, objectid etc<BR>><BR>> 2. Ideally I would like
to use the accordion layout for when there is more<BR>> than<BR>> one
queryable layer, but I can´t find any code to implement this. I have<BR>>
seen it<BR>> on Bryan Mcbrides explorer, but apart from that can´t find
any<BR>> documentation.<BR>><BR>> currently I have a popup designed
like this...<BR>><BR>><BR>> // create the popup<BR>> var
featureInfo = new OpenLayers.Control.WMSGetFeatureInfo({<BR>> queryVisible:
true,<BR>> highlightOnly: true,<BR>> maxFeatures: 5,<BR>> layers:
[layer_wea_wms,EnMap_SG_WEA_f]<BR>> });<BR>><BR>>
featureInfo.events.on({<BR>> getfeatureinfo: function(e)
{<BR>> new
GeoExt.Popup({<BR>>
title: "Position:<BR>>
"+mappanel.map.getLonLatFromPixel(e.xy).transform(epsg900913,
epsg4326),<BR>>
width: 400,<BR>> autoHeight: true,<BR>> layout: 'accordion',<BR>>
bodyStyle:
'background-color:#FFF;,font-size:14px;',<BR>>
autoScroll:
true,<BR>>
maximizable:
true,<BR>>
map:
mappanel.map,<BR>>
lonlat:
mappanel.map.getLonLatFromPixel(e.xy),<BR>>
html:'<p
style="font-size:10px;">Attributen</p><br>'+e.text,<BR>>
unpinnable:true,<BR>> anchored: true,<BR>> shadow: true,<BR>>
listeners:
{<BR>>
close: function()
{<BR>>
// closing a popup destroys it, but our reference<BR>> is<BR>>
truthy<BR>>
popup =
null;<BR>>
}<BR>> }<BR>>
}).show();<BR>> }<BR>> });<BR>><BR>>
map.addControl(featureInfo);<BR>>
featureInfo.activate();<BR>><BR>><BR>><BR>><BR>> thanks for any
help_______________________________________________<BR>> Users mailing
list<BR>> <A href="mailto:Users@geoext.org"
target=_blank>Users@geoext.org</A><BR>> <A
href="http://www.geoext.org/cgi-bin/mailman/listinfo/users"
target=_blank>http://www.geoext.org/cgi-bin/mailman/listinfo/users</A><BR>><BR><BR><BR></DIV></DIV></DIV></DIV>
<DIV
style="FONT-FAMILY: arial, helvetica, sans-serif"></DIV></DIV></DIV><BR>_______________________________________________<BR>Users
mailing list<BR><A href="mailto:Users@geoext.org">Users@geoext.org</A><BR><A
href="http://www.geoext.org/cgi-bin/mailman/listinfo/users"
target=_blank>http://www.geoext.org/cgi-bin/mailman/listinfo/users</A><BR><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Hugo Martins<BR>LabNT - ISEGI UNL<BR>Campus de
Campolide<BR>1070-312 Lisboa<BR>N 38°43'56.84", W 9°9'35.74"<BR></DIV>
<P>
<HR>
_______________________________________________<BR>Users mailing
list<BR>Users@geoext.org<BR>http://www.geoext.org/cgi-bin/mailman/listinfo/users<BR></DIV></DIV></DIV></BODY></HTML>