views:

249

answers:

1

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!

+1  A: 

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() + ")";
Rich Bennema
Thanks Rich, this appears to have me going in the right direction. I've implemented my own menu control, so now all that's left is to muck with the code a little bit.
SeanW
Well it half works... I think your answer is correct, that is the right place, and the right way to do it... but I'm having an issue with the count returned. It doesn't seem to be taking the view into account. I posted a new question because it seems to be independent of the navigation itself... take a look here: http://stackoverflow.com/questions/2478555/sharepoints-list-getitemsview-returns-all-items-instead-of-filtered-view-items
SeanW