Solved! Go to Solution.
override protected function commitProperties():void { super.commitProperties(); var featureLayer:FeatureLayer = hostComponent.featureLayer; var formattedAttributes:Object = hostComponent.formattedAttributes; var graphic:Graphic = hostComponent.graphic; var map:Map = hostComponent.map; var popUpInfo:PopUpInfo = hostComponent.popUpInfo; var validMediaInfos:Array = hostComponent.validPopUpMediaInfos; var geometry:Geometry = graphic ? graphic.geometry : null; var layerDetails:LayerDetails = featureLayer ? featureLayer.layerDetails : null; vGroup.removeAllElements(); //vGroup.addElement(ToggleLayers); if (popUpInfo) { if (popUpInfo.title) { titleText.text = StringUtil.substitute(popUpInfo.title, formattedAttributes); if (titleText.text) { vGroup.addElement(titleText); vGroup.addElement(titleLine); } } var htmlText:String; if (popUpInfo.description) { htmlText = StringUtil.substitute(popUpInfo.description, formattedAttributes); if (htmlText) { //Code Addition htmlText = replaceIsaiahsContent(htmlText); //End Code Addition var descriptionText:Text = new PopUpText(); descriptionText.percentWidth = 100; descriptionText.styleSheet = textStyleSheet; cleanAndSetHtmlText(descriptionText, htmlText); //trace(descriptionText.htmlText); vGroup.addElement(descriptionText); } } else { var descriptionForm:Form; for each (var fieldInfo:PopUpFieldInfo in popUpInfo.popUpFieldInfos) { if (fieldInfo.visible) { var formItem:FormItem = new FormItem(); formItem.label = fieldInfo.label || fieldInfo.fieldName; var label:Label; htmlText = formattedAttributes[fieldInfo.fieldName]; if (htmlText) { // convert attribute field values that just contain URLs into links var match:Array = htmlText.match(/^\s*((https?|ftp):\/\/\S+)\s*$/i); if (match && match.length > 0) { label = new Label(); htmlText = '<a href="' + match[1] + '" target="_blank">' + match[1] + "</a>"; } else { label = new PopUpText(); } cleanAndSetHtmlText(label, htmlText); label.selectable = true; label.styleSheet = this.textStyleSheet; label.width = 150; formItem.addChild(label); } if (!descriptionForm) { descriptionForm = new Form(); descriptionForm.percentWidth = 100; descriptionForm.horizontalScrollPolicy = ScrollPolicy.OFF; descriptionForm.verticalScrollPolicy = ScrollPolicy.OFF; descriptionForm.styleName = "formStyle"; } descriptionForm.addChild(formItem); } } if (descriptionForm) { vGroup.addElement(descriptionForm); } } if (validMediaInfos && validMediaInfos.length > 0) { vGroup.addElement(mediaBrowser); mediaBrowser.attributes = graphic.attributes; mediaBrowser.formattedAttributes = formattedAttributes; mediaBrowser.popUpFieldInfos = popUpInfo.popUpFieldInfos; mediaBrowser.popUpMediaInfos = validMediaInfos; } if (popUpInfo.showAttachments && graphic && featureLayer && layerDetails && layerDetails.hasAttachments && layerDetails.objectIdField) { vGroup.addElement(attachmentInspector); attachmentInspector.showAttachments(graphic, featureLayer); } if (map && geometry) { vGroup.addElement(zoomToButton); } } } //Code Addition private function replaceIsaiahsContent(content:String):String { content = content.replace("LMD 1","<a href='http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/1.asp' target='_blank'><b>LMD 1</b></a>"); content = content.replace("LMD 2","<a href='http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/2.asp' target='_blank'><b>LMD 2</b></a>"); content = content.replace("LMD 1, LMD 5","<a href='http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/1.asp' target='_blank'><b>LMD 1</b></a>"); return content; } //End Code Addition private function showHighlight(params:Array):void
{
var showHighlightPoint:MapPoint = params[0].point as MapPoint;
popUpRenderer.popUpInfo = configurePopUpInfo(params[0].graphic.attributes.links);
popUpRenderer.graphic = params[0].graphic;
popUpRenderer.setStyle("skinClass", widgets.eSearch.PopUpRendererSkin);
map.infoWindow.content = popUpRenderer;
map.infoWindow.contentOwner = popUpRenderer.graphic;
map.infoWindow.show(showHighlightPoint);
}
private function showHighlight(params:Array):void
{
var showHighlightPoint:MapPoint = params[0].point as MapPoint;
popUpRenderer.popUpInfo = configurePopUpInfo(params[0].graphic.attributes.link, params[0].graphic.attributes.linkalias);
popUpRenderer.graphic = params[0].graphic;
popUpRenderer.setStyle("skinClass", com.esri.ags.skins.PopUpRendererSkin);
map.infoWindow.content = popUpRenderer;
map.infoWindow.contentOwner = popUpRenderer.graphic;
map.infoWindow.show(showHighlightPoint);
}override protected function commitProperties():void
{
super.commitProperties();
var featureLayer:FeatureLayer = hostComponent.featureLayer;
var formattedAttributes:Object = hostComponent.formattedAttributes;
var graphic:Graphic = hostComponent.graphic;
var map:Map = hostComponent.map;
var popUpInfo:PopUpInfo = hostComponent.popUpInfo;
var validMediaInfos:Array = hostComponent.validPopUpMediaInfos;
var geometry:Geometry = graphic ? graphic.geometry : null;
var layerDetails:LayerDetails = featureLayer ? featureLayer.layerDetails : null;
vGroup.removeAllElements();
if (popUpInfo)
{
if (popUpInfo.title)
{
titleLabel.text = StringUtil.substitute(popUpInfo.title, formattedAttributes);
if (titleLabel.text)
{
vGroup.addElement(titleLabel);
vGroup.addElement(titleLine);
}
}
var htmlText:String;
if (popUpInfo.description)
{
htmlText = StringUtil.substitute(popUpInfo.description, formattedAttributes);
if (htmlText)
{
cleanAndSetHtmlText(descriptionText, htmlText);
vGroup.addElement(descriptionText);
}
//Fix for the 2.3.x popup text color bug RJS
descriptionText.styleSheet = textStyleSheet;
}
else
{
vGroup.addElement(descriptionForm);
descriptionForm.removeAllChildren();
for each (var fieldInfo:PopUpFieldInfo in popUpInfo.popUpFieldInfos)
{
if (fieldInfo.visible)
{
var formItem:FormItem = new FormItem();
formItem.label = fieldInfo.label || fieldInfo.fieldName;
var label:mx.controls.Label;
htmlText = formattedAttributes[fieldInfo.fieldName];
if (htmlText)
{
// convert attribute field values that just contain URLs into links
var match:Array = htmlText.match(/^\s*((https?|ftp):\/\/\S+)\s*$/i);
//convert attribute field values that contain specified values into links
var match24:Array = htmlText.match("LMD 1, LMD 5");
var match25:Array = htmlText.match("LMD 3A, LMD 3B");
var matchTwo:Array = htmlText.match("LMD 1");
var match3:Array = htmlText.match("LMD 2");
if (match && match.length > 0)
{
label = new mx.controls.Label();
htmlText = '<a href="' + match[1] + '" target="_blank">' + match[1] + "</a>";
} else if (match24 && match24.length > 0){
label = new mx.controls.Label();
htmlText = '<a href="http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/1.asp" target="_blank">' + '<b>LMD 1</b>' + '</a>' + ' ' + '<a href="http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/5.asp" target="_blank">' + '<b>LMD 5</b>' + "</a>";
}else if (match25 && match25.length > 0){
label = new mx.controls.Label();
htmlText = '<a href="http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/3A.asp" target="_blank">' + '<b>LMD 3A</b>' + '</a>' + ' ' + '<a href="http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/3B.asp" target="_blank">' + '<b>LMD 3B</b>' + "</a>";
}else if (matchTwo && matchTwo.length > 0){
label = new mx.controls.Label();
htmlText = '<a href="http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/1.asp" target="_blank">' + '<b>LMD 1</b>' + "</a>";
}else if (match3 && match3.length > 0){
label = new mx.controls.Label();
htmlText = '<a href="http://www.cityofrc.us/cityhall/admin/gis/districts/landscape/2.asp" target="_blank">' + '<b>LMD 2</b>' + "</a>";
}else{
label = new Text();
}
cleanAndSetHtmlText(label, htmlText);
label.selectable = true;
label.styleSheet = this.textStyleSheet;
label.width = 350;
formItem.addChild(label);
}
descriptionForm.addChild(formItem);
}
}
}
if (validMediaInfos && validMediaInfos.length > 0)
{
vGroup.addElement(mediaBrowser);
mediaBrowser.attributes = graphic.attributes;
mediaBrowser.formattedAttributes = formattedAttributes;
mediaBrowser.popUpFieldInfos = popUpInfo.popUpFieldInfos;
mediaBrowser.popUpMediaInfos = validMediaInfos;
}
if (popUpInfo.showAttachments && graphic && featureLayer
&& layerDetails && layerDetails.hasAttachments && layerDetails.objectIdField)
{
vGroup.addElement(attachmentInspector);
attachmentInspector.showAttachments(graphic, featureLayer);
}
if (map && geometry)
{
vGroup.addElement(zoomToButton);
}
}
}When you said to use the createSearchResults function did you mean try adding the same kind of match variable to that function as I did in the skin. That way the html going to the popUpInfo.description would be formatted into a link.That is exactly the approach you need to take. When you find your field you need to add text like this:
<br/><a href='yourURL'>" + linkText + "</a>