惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
IT之家
IT之家
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
小众软件
小众软件
博客园 - 叶小钗
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

博客园 - an_andy

MOSS 2007定制开发培训 Soft Skill MOSS2007 - Microsoft Release sample Master Pages Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation 招聘SharePoint Developer Office System 2007 update Office 2007 Beta2 Downloads WinFX SharePoint Search 文档管理[权限] GetUserProfilerWebPart 设计文档 Enterprise Library SQL Server Reporting Services 从应用程序生成用户友好的报表 Live Communications Server 2005 sp1 发布 Portal 个性登录页 显示wss图片库:速度 基于sharepoint 2003的内容管理1.0 Single Sing-On 单点登录 Visual Studio Tools For Office "v3" - March Community Technology Preview [CTP]
MOSS 2007: Implementing a custom Navigation
an_andy · 2007-04-28 · via 博客园 - an_andy

You can use the following code snippet to iterate through your navigation tree recursive:

using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing.Navigation;

public class SiteMapTest : System.Web.UI.WebControls.WebParts.WebPart
{

   protected
override void RenderContents(System.Web.UI.HtmlTextWriter writer)
   {
      PortalSiteMapProvider map = new PortalSiteMapProvider();
      writer.Write("<table>");
      this.PrintTree(map.RootNode, writer, 0);
      writer.Write("</table>");
   }

   public
void PrintTree(SiteMapNode node, System.Web.UI.HtmlTextWriter writer, int level)
   {
      string space = string.Empty;
      for (int i = 0; i < level; i++)
      {
         space += "&nbsp;&nbsp;&nbsp"&nbsp;&nbsp;&nbsp";
      }
      writer.Write("<tr><td>" + space + "<a href=\"" + node.Url + "\">" + node.Title + "</a></tr></td>");
      foreach (SiteMapNode childNode in node.ChildNodes)
      {
         PrintTree(childNode, writer, level + 1);
      }
   }

}

If you use a SPSiteMapProvider instead of PortalSiteMapProvider, you will only see your sites, no pages.
SPContentMapProvider delivers nothing for me, there are no ChildNodes defined. I didn't check out SPNavigationProvider, but I had some bad expierence with Microsoft.SharePoint.Navigation.SPNavigation.
For some more informations see: http://msdn2.microsoft.com/en-us/library/aa830815.aspx#Office2007SSBrandingWCMPart2_CustomizingNavigation