Replacing SharePoint 2010 Menu Control
步骤:
1.使用SharePoint Designer 打开需要修改的站点。找到母版页v4.master,右击选择复制,然后在粘贴,将其名字改成:v4_sample.master
当然你可以改成任何你喜欢的名字。
2.右击我们准备好的v4_sample.master,选择在高级模式下编辑文件
3.在编辑窗口找到下面的代码:
<SharePoint:AspMenu id="V4QuickLaunchMenu" runat="server" EnableViewState="false" DataSourceId="QuickLaunchSiteMap" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" SkipLinkText="" CssClass="s4-ql" />
然后用下面的代码替换:
<SharePoint:SPHierarchyDataSourceControl
id="MyTreeViewDataSource"
runat="server" RootContextObject="Web"
IncludeDiscussionFolders="true" />
<SharePoint:SPRememberScroll
id="MyTreeViewRememberScroll"
runat="server" onscroll="javascript:_spRecordScrollPositions(this);"
Style="overflow: auto;height: 400px;width: 150px; ">
<SharePoint:SPTreeView
id="MyWebTreeView"
runat="server"
ShowLines="true"
DataSourceId="MyTreeViewDataSource"
ExpandDepth="3"
SelectedNodeStyle-CssClass="ms-tvselected"
NodeStyle-CssClass="ms-navitem"
NodeStyle-HorizontalPadding="2"
NodeStyle-VerticalPadding="5"
SkipLinkText=""
NodeIndent="20"
ExpandImageUrl="/_layouts/images/tvplus.gif"
CollapseImageUrl="/_layouts/images/tvminus.gif"
NoExpandImageUrl="/_layouts/images/tvblank.gif" />
</SharePoint:SPRememberScroll>
效果图:
4.完成后保存该master文件,然后右击它,选择设置为默认母版页。
完成后,刷新站点,就可以看到效果了。
说明:
1.关于三个控件的msdn说明:
SPHierarchyDataSourceControl,SPRememberScroll,SPTreeView
2.原文地址:http://virtualizesharepoint.com/2011/03/04/replacing-sharepoint-2010-menu-control/