开发者

How to hide a SharePoint tab on 100 sites? (SP2010)

I have 100 team sites in SharePoint 2010. At the last minute, I have been asked to hide a tab on each of these sites.开发者_Go百科 Through the GUI, I could do this by using the Navigation option under Site Settings, but I would have to do it for all 100 sites. Is there a way to do this programmatically? Or globally through the GUI (I doubt this is an option)? I have tried using JQuery, but due to the lag, it is not a viable option. I figured there may also be the possibility to write a powershell script to do this - I am just still new to powershell.

Thoughts? Thanks.


You should use something like this in your Console application:

SPSite site = new Site("http://yoursite");
foreach (SPWeb web in site.AllWebs)
{
    foreach(SPNavigationNode node in web.Navigation.TopNavigationBar)
    {
        if (node.Title == "Test")
        {
            node.IsVisible = false;
            node.Update();
        }
    }
    web.Dispose();
}
site.Dispose();

This script will hide all nodes with title "Test". You can also use Url property to determine if the node needs to be hidden.

Here I expect, that you need to change navigation of 100 child webs in site collection "http://yoursite".

P.S. Please, make sure, that you target .Net Framework 3.5 in your Console App, and AnyCPU platform is specified in Visual Studio project properties. Or you can get errors saying that your site not found.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜