Try Now
More in this section

Forums / Developing with Sitefinity / Search Results Custom Link

Search Results Custom Link

2 posts, 0 answered
  1. Kevin Brydon
    Kevin Brydon avatar
    3 posts
    11 Feb 2014
    26 Apr 2014
    Link to this post


    I have several hundred "Vehicle" content items. These items are not linked to any page directly, instead there is a single page with a custom widget which reads and displays a specific Vehicle based on querystring ID e.g. /display-vehicle?VehicleId=4EE2CDAD-E682-4282-8B96-E93342755892. There is a search index on these "Vehicle" items. There is a page with a search input that uses this index and a search results widget that displays the results of a search.

    As the "Vehicle" content items are not linked to a page the links in the search results do not work (empty href). I would like to customise the link so that it references "/display-vehicle?VehicleID={{ID}}".

    I understand that the solution may be to write a custom widget that inherits the SearchResults class but am stuggling to find any official documentation aside from forum posts.

    Any ideas?

  2. Kevin Brydon
    Kevin Brydon avatar
    3 posts
    11 Feb 2014
    26 Apr 2014 in reply to Kevin Brydon
    Link to this post

    I was thinking too much about it. The search results expose the ID of the content item so I can just modify the <a> tag as below.

    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
    <%@ Register Assembly="Telerik.Sitefinity.Search.Impl" Namespace="Telerik.Sitefinity.Services.Search.Web.UI.Public" TagPrefix="sfSearch" %>
    <sfSearch:SearchBox ID="topSearchBox" runat="server" />
    <sitefinity:SitefinityLabel id="resultsStats" runat="server" WrapperTagName="p" CssClass="sfsearchResultStatistics" Text="<%$Resources:SearchResources, SearchResultsStatusMessage %>" />
    <asp:Repeater ID="resultsList" runat="server">
            <dl class="sfsearchResultsWrp sfsearchReultTitleSnippetUrl">
            <dt class="sfsearchResultTitle"><a runat="server" href='<%# "/display-vehicle?id=" + Eval("Id") %>'><%# Eval("Title") %></a></dt
            <dd class="sfsearchResultSnippet"><%# Eval("Summary")%></dd>
            <dd class="sfsearchResultUrl"><a runat="server"  href='<%# Eval("Link")%>'><%# Eval("Link")%></a></dd>
            <dd class="sfsearchResultHighLighter"><%# Eval("HighLighterResult")%></dd>
    <sitefinity:Pager ID="pager" runat="server" />
    <sfSearch:SearchBox ID="bottomSearchBox" runat="server" />
2 posts, 0 answered