自定义SharePoint导航,链接到列表视图 [英] Custom SharePoint navigation, linking to list views
问题描述
我已经有一个解决方案(WSP)了,而且已经使用了一段时间了.我一直在使用内置工具在左侧导航菜单中创建分层导航,但是现在我真的想对其进行自定义.我的菜单看起来像这样:
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.
有人可以指出我的写作方向吗?我在项目中使用WSPBuilder-如果可能的话,我希望将其包装在我的解决方案中,如果没有的话,不用担心...
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...
感谢所有指针!
推荐答案
默认情况下,SharePoint主页面使用菜单控件. AspMenu类是密封的,但是可以下载该代码
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() + ")";
这篇关于自定义SharePoint导航,链接到列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!