Reputation: 12806
In SharePoint 2013 I want to programmatically set the search results url. There doesn't appear to be a setting at the root web or site level that appears to allow for this assignment. With a powershell dictionary dump $mySite.RootWeb.AllProperties
, I see that there are some properties at the root web that look like the likely suspects SRCH_ENH_FTR_URL_SITE
, SRCH_ENH_FTR_URL_WEB
, SRCH_ENH_FTR_URL
; however, I'm left to guess what these values refer too though. What is the proper way to programmatically set the search results url in SharePoint 2013?
Upvotes: 1
Views: 4175
Reputation: 12806
The solution to this is to set the SRCH_SB_SET_SITE
root web property with a JSON string as follows:
{"Inherit":false,"ResultsPageAddress":"~sitecollection/Pages/SearchResults.aspx","ShowNavigation":false}
C# code:
rootWeb.AllProperties["SRCH_SB_SET_SITE"] = "{\"Inherit\":false,\"ResultsPageAddress\":\"~sitecollection/Pages/SearchResults.aspx\",\"ShowNavigation\":false}";
rootWeb.Update();
Upvotes: 7