私はMOSS公開サイト用のサイトマップを作成しようとしていますが、2つの方法がありますが、どちらにも固執しているようです。 (例えばリスト、surverys)Sharepoint/MOSSサイトマップを作成する
私の最初のアプローチは、すでに作成され、きれいにキャッシュされているPortalSiteMapProvider、...
PublishingWeb rootWeb = PublishingWeb.GetPublishingWeb(SPContext.Current.Site.RootWeb);
//Get the URL of the default page in the web
string defaultPageUrl = rootWeb.DefaultPage.ServerRelativeUrl;
PortalListItemSiteMapNode webNode = (PortalListItemSiteMapNode)PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode.FindSiteMapNode(defaultPageUrl);
HttpContext.Current.Response.Output.WriteLine("Top Level: " + webNode.Title.ToString() + "<br />");
//iterate through each one of the pages and subsites
foreach (SiteMapNode smnTopLevelItem in webNode.ParentNode.ChildNodes)
{
HttpContext.Current.Response.Output.WriteLine(smnTopLevelItem.Title.ToString() + "<br />");
//if the current sitemap has children, create a submenu for it
if (smnTopLevelItem.HasChildNodes)
{
foreach (SiteMapNode smnChildItem in smnTopLevelItem.ChildNodes)
{
HttpContext.Current.Response.Output.WriteLine(smnChildItem.Title.ToString() + "<br />");
}
}
}
HttpContext.Current.Response.End();
を使用することですが、これは、サイトコレクションのすべてを返すようです。私はSharepoint websを見せたいだけです。
私の他のアプローチは..コードのこの部分を使用するために離れてフラットリスト内のすべてのウェブを返すの問題から、完璧で
SPSite siteCollection = new SPSite("http://example.org");
SPWebCollection sites = siteCollection.AllWebs;
foreach (SPWeb site in sites)
{
Console.WriteLine(site.Title.ToString() + " " + site.ServerRelativeUrl.ToString());
}
ました。
理想的には、子Webを表示するためにインデントを追加できます。
OK涼しい、私はPortalSiteMapProviderを使用したいが、私は唯一のウエブに出力を制限する方法がわかりませんよ。 – Rob