Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

Thank you

share|improve this question
    
0% accept rate? You need to go back and set some answers to the questions you asked. –  Mike Oct 5 '12 at 18:00

2 Answers 2

up vote 0 down vote accepted

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

share|improve this answer
 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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