Search Results Custom Link
Hi,
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?
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"
>
<
HeaderTemplate
>
<
dl
class
=
"sfsearchResultsWrp sfsearchReultTitleSnippetUrl"
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
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
>
</
ItemTemplate
>
<
FooterTemplate
>
</
dl
>
</
FooterTemplate
>
</
asp:Repeater
>
<
sitefinity:Pager
ID
=
"pager"
runat
=
"server"
/>
<
sfSearch:SearchBox
ID
=
"bottomSearchBox"
runat
=
"server"
/>