2007年4月28日

MOSS 2007: Implementing a custom Navigation

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

posted @ 2007-04-28 21:41 an_andy 阅读(658) 评论(0) 编辑

MOSS2007 - Microsoft Release sample Master Pages

come from helloitsliam

Microsoft has made available four sample master page sets compatible with the Application Templates for Microsoft Windows SharePoint Services 3.0 to showcase some of the customization options master pages provide. These can be downloaded here:

http://www.microsoft.com/downloads/details.aspx?familyid=7c05ca44-869a-463b-84d7-57b053711a96&displaylang=en&tm

If you want to have look at them pop over to the links below:

Block http://www.wssdemo.com/pages/master%20block.aspx

Clarity http://www.wssdemo.com/pages/master%20clarity.aspx

Horizon http://www.wssdemo.com/pages/master%20horizon.aspx

Reverse http://www.wssdemo.com/pages/master%20reverse.aspx

Have fun.

posted @ 2007-04-28 21:34 an_andy 阅读(549) 评论(0) 编辑

Customizing the Quick Launch menu: Adding fly-out menus to SharePoint navigation

come from SharePoint Team Blog

In this post, I’ll show you how to customize the Quick Launch menu to display several levels of data in a dynamic way and use this customized menu for quick access to all Views within a List without consuming space on the Quick Launch.

First, let’s add a List and make sure it shows on the Quick Launch. Let’s call this list “Navigation Test List”, and then add 4 Views to the list.

Next, let’s write some OM code that, when run, adds a link to each of the List’s Views under the List Link on the Quick Launch. Add the following code to a new C# Console Application in Visual Studio .NET or 2005 (and don’t forget to add a reference to Microsoft.Sharepoint.dll).

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Navigation;

 

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            SPSite site = new SPSite("http://server");

            SPWeb web = site.OpenWeb();

            SPList list = web.Lists["Navigation Test List"];

            SPNavigationNode rootListLink = web.Navigation.GetNodeByUrl(list.DefaultViewUrl);

            SPNavigationNode node = null;

            foreach (SPView view in list.Views)

            {

                node = new SPNavigationNode(view.Title, view.Url, false);

                rootListLink.Children.AddAsFirst(node);

            }

        }

    }

}

 

At this point, we have links to all of the Views under the List, but they cannot be displayed since the menu control ignores the links after the second level. So, let’s modify the menu control to display what we want. Perform the following to accomplish this task:

 

1.     Navigate to the master page gallery: From the home page click on Site Actions, then Site Settings, and then on Master Pages, under the Galleries column

2.     Click on the drop down menu for the master page you want to modify, and then click on Edit in Microsoft Office SharePoint Designer

3.     Locate the Quick Launch Menu control, and modify the StaticDisplayLevels and MaximumDynamicDisplayLevels attributes:

                     <SharePoint:AspMenu

                            id="QuickLaunchMenu"

                            DataSourceId="QuickLaunchSiteMap"

                            runat="server"

                            Orientation="Vertical"

                            StaticDisplayLevels="2"

                            ItemWrap="true"

                            MaximumDynamicDisplayLevels="1"

                            StaticSubMenuIndent="0"

                            SkipLinkText="">

                           

4.     Save your changes and reload the page from the browser. Hover over the Links on the Quick Launch. The end result should look like this:

 

5.     Optional: Modify other properties in the menu control to match the look and feel of your site. The above steps can also be applied to the Top Link Bar.

 

Useful Links:

·         On MSDN, How to: Customize the Display of Quick Launch.

posted @ 2007-04-28 20:29 an_andy 阅读(966) 评论(1) 编辑