自定义 SharePoint 导航,链接到列表视图

发布于 2024-08-25 04:17:55 字数 519 浏览 4 评论 0原文

我已经有一个解决方案(WSP)了,我已经工作了一段时间了。我一直在使用内置工具在左侧导航菜单中创建分层导航,但我现在想真正对其进行自定义。我的菜单看起来有点像这样:

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

每个链接都链接到一个自定义视图,全部用于同一个列表。我想做的是让导航看起来像这样:

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

区别在于我想显示每个视图包含多少个列表项。我确信我必须手动编写一些代码,这不是问题 - 但我真的不知道从哪里开始。

有人可以指出我的写作方向吗?我在我的项目中使用 WSPBuilder - 如果可能的话,我想将其包含在我的解决方案中,如果没有,不用担心......

感谢您的所有指点!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半边脸i 2024-09-01 04:17:55

默认情况下,SharePoint 母版页使用 AspMenu 控件,它只是 ASP.NET 菜单控制。 AspMenu 类已密封,但代码可供下载 此处。根据代码,没有任何内容指向该列表,但您可以使用代码编写自己的控件,然后将其放入母版页中。这只是测试代码,但也许 OnMenuItemDataBound 中类似以下的代码可以工作:

        SPWeb web = SPContext.Current.Web;
        SPView view = web.GetViewFromUrl(e.Item.NavigateUrl);
        int count = view.ParentList.GetItems(view).Count;
        e.Item.Text += " (" + count.ToString() + ")";

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() + ")";
一绘本一梦想 2024-09-01 04:17:55

这是另一个使用 sharepoint 内置导航功能的解决方案。您可以在站点设置>导航中输入所有导航信息。然后您可以使用 asp:repeater 来设置您想要的菜单样式。

http://sharepoint2010customnavigation.blogspot.com/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文