如何以编程方式关闭共享点导航中的显示页面

发布于 2024-07-08 06:59:04 字数 247 浏览 5 评论 0原文

我正在使用编程方式创建 SharePoint 网站,

SPWeb spWeb = spSite.AllWebs.Add(...);

我需要运行哪些代码来设置 spWeb 以关闭“在导航中显示页面”选项?

答案:

publishingWeb.IncludePagesInNavigation = false;

I am progamatically creating a SharePoint site using

SPWeb spWeb = spSite.AllWebs.Add(...);

What code do I need run to set the spWeb to turn off the "Show pages in navigation" option?

Answer:

publishingWeb.IncludePagesInNavigation = false;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野却迷人 2024-07-15 06:59:04

我自己也不确定,但我能够找到这个

修改导航是另一种常见的情况
品牌推广任务,因为它会影响什么
用户可以看到以及如何继续
通过站点层次结构。 这
Microsoft.SharePoint.Publishing
命名空间公开了几个类
定位发布网站
基础设施,例如 PublishingWeb
和发布页面。 使用这些
类,我们可以轻松修改
每个站点的导航。 如果你想
显示为根级别的子 Web
网站全球导航,第一轮
从父站点继承,
像这样:

publishingWeb.InheritGlobalNavigation = false;

您可能还想隐藏所有网站
来自全球导航的页面。 环境
IncludePagesInNavigation 设置为 false
隐藏网站中的所有页面,
无论是否
发布页面.InludeInGlobalNavigation
属性设置为 true

// do not show pages in navigation
publishingWeb.IncludePagesInNavigation = false;

如果您正在处理默认站点
不继承自 PublishingWeb,
仍然可以隐藏这些
全局导航栏中的站点。
例如,如果您创建一个网站
使用协作收集
门户模板并想要排除
来自全球导航的新闻网站,
将该网站添加到
__GlobalNavigationExcludes 网站的属性:

string globalNavExcludes = String.Empty;
SPWeb webSite = MSDNSiteCollection.RootWeb;
// _GlobalNavigationExcludes property contains a delimited string of 
// GUIDs identifying the Id of each site to be excluded from global
// navigation

if (webSite.AllProperties.ContainsKey("__GlobalNavigationExcludes")) {
  globalNavExcludes = 
    webSite.AllProperties["__GlobalNavigationExcludes"].ToString();
}

SPWeb newsSite = MSDNSiteCollection.AllWebs["News"];
// string is delimited "{GUID};{GUID};",
// use format code B to convert to string
globalNavExcludes += String.Concat(currentWeb.ID.ToString("B"), ";");

webSite.AllProperties["__GlobalNavigationExcludes"] = globalNavExcludes;
webSite.Update();

将导航节点直接添加到
SPNavigationNodeCollection 是一个不错的
只显示你想要的节点的方法
以及对节点和链接进行分组
外部网站。 图 10 显示了如何
添加内部链接、外部链接、
以及全球导航的航向
酒吧。 这个例子解决了一些问题
SPNavigation 的属性
影响是否链接的类
在新窗口中打开以及如何
处理空 URL。

Wasn't sure myself but I was able to locate this:

Modifying navigation is another common
branding task since it affects what
users can see and how they can proceed
through a site hierarchy. The
Microsoft.SharePoint.Publishing
namespace exposes several classes that
target the Publishing site
infrastructure, such as PublishingWeb
and PublishingPage. Using these
classes, we can easily modify
navigation for each site. If you want
a child Web to display as a root level
site in global navigation, first turn
off inheritance from the parent site,
like so:

publishingWeb.InheritGlobalNavigation = false;

You might also want to hide all site
pages from global navigation. Setting
IncludePagesInNavigation to false
hides all pages in the site,
regardless of whether the
PublishingPage.IncludeInGlobalNavigation
property is set to true

// do not show pages in navigation
publishingWeb.IncludePagesInNavigation = false;

If you are dealing with default sites
that don't inherit from PublishingWeb,
it's still possible to hide these
sites from the global navigation bar.
For example, if you create a site
collection using the collaboration
portal template and want to exclude
the News site from global navigation,
add that site to the
__GlobalNavigationExcludes property of the site:

string globalNavExcludes = String.Empty;
SPWeb webSite = MSDNSiteCollection.RootWeb;
// _GlobalNavigationExcludes property contains a delimited string of 
// GUIDs identifying the Id of each site to be excluded from global
// navigation

if (webSite.AllProperties.ContainsKey("__GlobalNavigationExcludes")) {
  globalNavExcludes = 
    webSite.AllProperties["__GlobalNavigationExcludes"].ToString();
}

SPWeb newsSite = MSDNSiteCollection.AllWebs["News"];
// string is delimited "{GUID};{GUID};",
// use format code B to convert to string
globalNavExcludes += String.Concat(currentWeb.ID.ToString("B"), ";");

webSite.AllProperties["__GlobalNavigationExcludes"] = globalNavExcludes;
webSite.Update();

Adding navigation nodes directly to an
SPNavigationNodeCollection is a good
way to display only the nodes you want
as well as to group nodes and links to
external sites. Figure 10 shows how to
add an internal link, external link,
and a heading to the global navigation
bar. This example addresses some of
the properties of the SPNavigation
class that affect whether the link
opens in a new window and how to
handle empty URLs.

汹涌人海 2024-07-15 06:59:04

对于 SP 2010,请使用以下...

publishingWeb.Navigation.GlobalIncludePages = false;

For SP 2010 use below...

publishingWeb.Navigation.GlobalIncludePages = false;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文