Remove search “this site” from the Search dropdownMarch 22, 2008 12:09
As described in this post at TechNet you can disable the option by editing the OSearchEnhancedFeature, but this would affect all sites, and editing standard features is not a clean option as it might be overwritten with service packs. I decided to remove the dropdown value with the help of some javascript. Just insert a Content Editor Web Part and insert the following javascript code:
<script language=”javascript”>
var searchDropDown = document.all.ctl00$PlaceHolderSearchArea$ctl01$SBScopesDDL; var removeID = 100; for (var x = 0; x <= searchDropDown.options.length-1; x++) { if (searchDropDown.options[x].value=="This Site") { removeID = x; } } if (removeID<100) { searchDropDown.remove(removeID); } </script> This code will remove the option from the dropdown and it’s tested in IE and Firefox. You can also download this preconfigured Web Part and add it to the required page. Enjoy! Tags: Content Editor Web Part, javascript, OSearchEnhancedFeature, search, search center, technet.Change the Subsites and Pages navigation setting by codeFebruary 27, 2008 11:12It took me quite some time to figure out how to change the Subsites and Pages settings by code. I finally manged to change them. The setting “Show subsites” can be altered in 2 ways. I was only able to change the “Show pages” on a publishing site.
Method 1 (”Show subsites” only)
SPWeb web = new SPSite(webCollection).OpenWeb();
web.AllProperties["__IncludeSubSitesInNavigation"] = “False”; web.Update(); web.Close(); web.Dispose(); Method 2
SPWeb web = new SPSite(webCollection).OpenWeb();
Tags: code, IncludePagesInNavigation, IncludeSubSitesInNavigation, pages, publishing, site, subsites, __IncludeSubSitesInNavigation.
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web); publishingWeb.IncludePagesInNavigation = false; publishingWeb.IncludeSubSitesInNavigation = false; publishingWeb.Update(); publishingWeb.Close(); web.Close(); web.Dispose(); |
||