Custom SharePoint navigation, linking to list view

2019-07-27 06:57发布

I've got a solution (WSP) I've been working in for quite some time now. I've been using the built in tools to create a hierarchical navigation in my left nav menu, but I'd like to really customize that now. My menu looks somewhat like this:

Menu Header 1
  Link 1a
  Link 1b
Menu Header 2
  Link 2a
  Link 2b

Each of the links links to a custom view, all for the same list. What I'd like to do is have the navigation look like this:

Menu Header 1 (8)
  Link 1a (3)
  Link 1b (5)
Menu Header 2 (12)
  Link 2a (4)
  Link 2b (8)

The difference being that I'd like to show how many list items each view contains. I'm sure I'll have to hand code something, that's not a problem - but I'm really not even sure where to begin.

Can someone point me in the write direction? I'm using WSPBuilder in my project - I'd like to wrap this up in my solution if possible, if not, no worries...

Thanks for any and all pointers!

2条回答
We Are One
2楼-- · 2019-07-27 07:52

By default, SharePoint master pages use the AspMenu control, which is only a thin wrapper around the ASP.NET Menu control. The AspMenu class is sealed, but the code is available for download here. Based on the code, there is nothing that points to the list, but you could use the code to write your own control and then place it into your master page. This is just test code, but perhaps something like the following in OnMenuItemDataBound would work:

        SPWeb web = SPContext.Current.Web;
        SPView view = web.GetViewFromUrl(e.Item.NavigateUrl);
        int count = view.ParentList.GetItems(view).Count;
        e.Item.Text += " (" + count.ToString() + ")";
查看更多
神经病院院长
3楼-- · 2019-07-27 07:55

Here is another solution that uses the built in navigation features of sharepoint. You can enter in all the navigation information in the site settings>navigation. Then you can style the menu however you want using a asp:repeater.

http://sharepoint2010customnavigation.blogspot.com/

查看更多
登录 后发表回答