English

How To: Customize search results with a 'Share' link for sharing metadata records directly from search pages

Summary

Instructions provided describe how to customize search results with a 'Share' link for sharing records that appear in the search results page. The Share link allows users to bookmark (i.e., Add to Favorites) or share (i.e., through Digg, MySpace, Google, etc.) a particular metadata record directly from the search results page using technology from AddThis.
[O-Image] Share Button

Procedure

Follow the steps below to add the 'Share' link to the Portal Implementation. To perform this customization, access to the Portal .jsp files on the GPT9 Web application server are necessary.

  1. Navigate to the <TOMCAT>\webapps\GPT9\catalog\search folder.
  2. Open the 'results.jsp' file in a text editor.
  3. At the top of the file, add some javascript tags. Find where it says “<% // scripting functions %>" and paste the following just underneath the "<f:verbatim>" tag:
    Code:
    <script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js">
    <script type="text/javascript">
    var addthis_pub=" ";
    </script>

  4. Now, find in the 'results.jsp' file where the "<% // Resource links %><h:panelGroup>" output links are defined. Add a new "< h:outputLink>" section, right above the line that says, “<% // Zoom map”.

    Paste the following code:
    Code:
    <% // Share result %>
    <h:outputLink id="_lnkShare" rendered="#{record.viewMetadataUrl != ''}"
    value="http://www.addthis.com/bookmark.php?v=20" styleClass="resultsLink"
    onmouseover="return addthis_open(this, '', '#{record.viewMetadataUrl}', '#{record.title}')"
    onmouseout="addthis_close()" onclick="return addthis_sendto()">
    <h:outputText id="_txtShareThis" value="#{gptMsg['catalog.search.searchResult.share']}" />
    </h:outputLink>

  5. Save the 'results.jsp' file and close it.
  6. Navigate to the <TOMCAT>\webapps\GPT9\WEB-INF\classes\gpt\resources folder. Open the 'gpt.properties' file in a text editor.
  7. Add the following resource key under the "# search related pages" heading. The resource key is the name of the link that appears in the search results user interface. To have it say something besides 'Share', replace the text after the equals sign with a title for the link:
    Code:
    catalog.search.searchResult.share = Share

  8. Save the 'gpt.properties' file and close it.
  9. Restart Tomcat, and do a search to see the new 'Share' link in each search result.