Skip to content

Add Custom Link to a Search Result

Christine White edited this page May 7, 2013 · 5 revisions

When search results are returned on a Geoportal Search page, there are links associated with the result by default. These links typically Details, Metadata, Zoom To, Preview, and others (see topic on How to Use Search Page Results).

This topic describes how to add a new custom link to the search results. This is useful for integrating additional functionality triggered by clicking the link on the search result. For example, perhaps you want to display a link for 'FTP download' that opens an FTP link described in metadata documents in your geoportal. You could customize the geoportal such that it displays this FTP download link with the search result, and when clicked, calls the FTP URL described in the metadata document.

This topic provides instructions, using the FTP download as an example. Steps are described below.

Table of Contents

Decide what information should be retrieved

The first step is to decide what information from your metadata document should be retrieved when the custom link is clicked. In our example, we want to retrieve FTP URLs for our registered resources. The sample FGDC metadata.xml we will use has the ftp URL located at the Network Resource Name metadata element, which is called <networkr></networkr>. It is found at the following xpath:

/metadata/distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr

Identify the metadata element you would like to access with your new link, and write down its xpath from the metadata.

Verify the xpath's index

The geoportal is going to use CSW protocol to retrieve information when the custom link is clicked. You must verify that the information you want to access is already indexed; if not, you will need to create an index for it and map it to the xpath you wrote down in the step above. For instructions how to verify your xpath is already indexed or to set the indexing for that xpath, read and follow guidance from Details of Lucene Indexing in the Geoportal. In our example, the <networkr></networkr> element will be indexed as a new property-meaning, and afterwards must be referenced in the fgdc-indexables.xml file. Tip: If you are adding a property-meaning for your index, it is recommended to model the new property-meaning after a similar property meaning in the property-meanings.xml file. Because our example is for an FTP site, we model it after the property-meaning for resource.url. We copy the property-meaning element for the resource.url, and paste it above in the property-meanings.xml file. Then we update the property-meaning name to a new value, e.g., networkr, and the scheme to a unique value, e.g., 'urn:x-esri:specification:ServiceType:Networkr', such that our new property meaning looks like the following:

<property-meaning name="networkr" valueType="String" comparisonType="value">
  <dc name="dct:references" scheme="urn:x-esri:specification:ServiceType:Networkr"/>
</property-meaning>

Save the file, but do not close it.

Verify the full CSW access

After you have verified that the xpath is indexed, you should be familiar with the property-meanings.xml file. Open this file again, and scroll to the where the 'Dublin Core response property sets' are defined. Find the full element, and then the dc element within it. Is the property-meaning that is mapped to your index in the list of meaning-names information? If not, you need to add it to one of the meaning-names elements. Enter the same name you used for the 'name' attribute of the property-meaning, and put it in the meaning-names element where it makes most sense. For example, because in our example we are adding a link for an FTP site, it makes sense that we would include our new property meaning in the <meaning-names></meaning-names> element that has other URL references. Therefore, our example looks like this:

<full>
  <dc>
    <meaning-names>fileIdentifier,uuid,title</meaning-names>
    <meaning-names>contentType,dataTheme</meaning-names>
    <meaning-names>dateModified,abstract</meaning-names>
    <meaning-names>resource.url,website.url,thumbnail.url,xml.url,networkr</meaning-names>
    <meaning-names>geometry,date,relation</meaning-names>
  </dc>
</full>

Save the file.

Update the Geoportal's CSW Response xslt

Now that you have added a new index and/or verified that it referenced in the property-meanings.xml and indexables.xml file, you will add code to the Geoportal's CSW response xslt such that a link is rendered from the CSW response from your index.

Open \\geoportal\WEB-INF\classes\gpt\search\profiles\CSW_2.0.2_OGCCORE_ESRI_GPT_GetRecords_Response.xslt. Add the following in between the closing Types and the closing Record elements:

<Links>
  <Link label="catalog.property.customLink.label.esri">
    <xsl:value-of select="./dct:references[@scheme='urn:x-esri:specification:ServiceType:Networkr']"/>
  </Link>
</Links>

Update the value in the @scheme value to be the same as the 'scheme' value from the property-meaning you defined in the property-meanings.xml file earlier. Note that in our example, we've used the scheme value urn:x-esri:specification:ServiceType:Networkr.

This code will add a new link to the search result that calls through CSW the information indexed at that scheme.

Save the file.

Update gpt.properties with the link's label

As a final step, open \\geoportal\WEB-INF\classes\gpt\resources\gpt.properties, and add a value that will represent the name of the new link to appear on the search result:

catalog.property.customLink.label.esri = CustomLink

Note: It doesn't matter where in the gpt.properties file you add this value. However, the value should begin with the term 'catalog'.

Test

Upload a sample metadata document that contains information at the xpath that you used in this customization. Approve the document. Now do a search from the geoportal search page. When you see your record in the results, expand it to verify that your custom link appears.

Clone this wiki locally