0

I want to check SPWeb reference if it is a search site. How can i do this by code.

Thank you

0

2 Answers 2

0

If myWeb.Template property is one the following, this is a search site :

  • SRCHCENTERFAST
  • SPSPORTAL
  • SRCHCEN
  • BLANKINTERNETCONTAINER (actually, it contains a subweb that can do search)

FYI, this list is computed by using this Powershell command :

Get-SPWebTemplate | ? { $_.description -match "search"}

You have to take into consideration that a "search" site is only a web site where the related web parts are put on pages. A search site can be customized to remove the search, and an another kind of web can add the web parts to be able to search

1
 site.WebTemplate == "SRCHCENTERLITE" ||
 site.WebTemplate == "SRCHCEN" ||
 site.WebTemplate == "SRCHCENTERFAST"

Where site is a SPWeb should get you all the OOTB search templates (as a conditional of course). I used this code in a site branding project to set my custom search master page instead of the other custom master page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.