/// <summary> /// When the page is loaded a search is carried out based on the 'q' query string parameter /// </summary> protected override void OnLoad(System.EventArgs e) { base.OnLoad(e); if (!IsPostBack) // Searches are performed by a page load with a 'q' querystring parameter, not through postback { var query = Request.QueryString["q"]; if (!String.IsNullOrEmpty(query)) { SearchKeywords.Text = query; // Configure search options if (SearchSettings.Config.Active) { SearchDataSource.PageLink = PageReference.StartPage; // Search within the current site SearchDataSource.LanguageBranches = ContentLanguage.PreferredCulture.Name; SearchDataSource.SearchLocations = "~/Global/,~/Documents/,~/PageFiles/"; // TODO Get VPP providers from config instead? SearchDataSource.Selected += HandleErrors; DisplaySearchResult(); } } } // Databind for translations SearchButton.DataBind(); }
/// <summary> /// When the page is loaded a search is carried out based on the 'q' query string parameter /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) // Searches are performed by a page load with a 'q' querystring parameter, not through postback { var query = Request.QueryString["q"]; if (!String.IsNullOrEmpty(query)) { SearchKeywords.Text = query; // Configure search options if (ServiceLocator.Current.GetInstance <SearchOptions>().Active) { SearchDataSource.PageLink = SiteDefinition.Current.StartPage.ToPageReference(); // Search within the current site SearchDataSource.LanguageBranches = ContentLanguage.PreferredCulture.Name; SearchDataSource.Selected += HandleErrors; DisplaySearchResult(); } } } // Databind for translations SearchButton.DataBind(); }
/// <summary> /// When the page is loaded a search is carried out based on the 'q' query string parameter /// </summary> protected override void OnLoad(EventArgs eventArgs) { PublicProxyPath = ServiceLocator.Current.GetInstance <IFindUIConfiguration>().AbsolutePublicProxyPath(); //detect if serviceUrl and/or defaultIndex is configured. IsConfigured = SearchIndexIsConfigured(EPiServer.Find.Configuration.GetConfiguration()); if (IsPostBack) { Query = srchTxt.Text; PagingPage = 1; } else { Query = Request.Params["q"]; srchTxt.Text = Query; PagingPage = Request.Params["p"].IsNotNullOrEmpty() ? int.Parse(Request.Params["p"]) : 1; } if (IsConfigured && !string.IsNullOrWhiteSpace(Query)) { var query = BuildQuery(); //Create a hit specification to determine display based on values entered by an editor on the search page. var hitSpec = new HitSpecification { HighlightTitle = CurrentPage.HighlightTitles, HighlightExcerpt = CurrentPage.HighlightExcerpts, ExcerptLength = CurrentPage.ExcerptLength }; try { Hits = query.GetResult(hitSpec); } catch (WebException wex) { IsConfigured = wex.Status != WebExceptionStatus.NameResolutionFailure; } DisplaySearchResult(); } // Databind for translations SearchButton.DataBind(); RequireClientResources(); }