+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Override the search function from a Custom Search Box

Override the search function from a Custom Search Box

3 posts, 0 answered
  1. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    12 Jan 2012
    Link to this post
    I need to create a custom search box for the site because the site needs to log the terms that customers are searching for. How can I achieve that? Is it possible to override the button click event for the search box? Thanks.

    Stephen
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Jan 2012
    Link to this post
    Hello,

    Since the search box makes a redirect to the search result page you will not be able to process the click postback event of the search button. The easiest way to achieve this is to do this in the control template for the Search Result control. Here is how you can get the catalog and the query passed to the search result:

    1) Open your website in VS and go to ~/Sitefinity/ControlTemplates/Search/SearchResult.ascx.
    2) Modify it as follows:
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %>
    <%@ Register Assembly="Telerik.Search" Namespace="Telerik.Search.WebControls.Admin"
        TagPrefix="sfSrc" %>
     
    <script runat="server" type="text/C#">
        protected void Page_Load()
        {
            var searchResultsControl = this.Parent.Parent;
            string query;
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["SearchQuery"]))
                query = HttpContext.Current.Request.QueryString["SearchQuery"];
            string catalogue;
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["IndexCatalogue"]))
                catalogue = HttpContext.Current.Request.QueryString["IndexCatalogue"];
        }
    </script>


    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Gaurav
    Gaurav avatar
    6 posts
    Registered:
    25 Jun 2012
    28 May 2012
    Link to this post
    Hi

    How can i get access to the object which contains the search results?
    e.g. If i extend the LuceneResultSet class --> LuceneResultSetNew : LuceneResultSet, how and where i can get hold of the object of type  LuceneResultSetNew  in my CustomeSearchResult class which is used to display the search results

    Note CustomeSearchResult is extending SearchResults


Register for webinar
3 posts, 0 answered