It’s a fairly known technique to make use of CustomActions to add elements to the out-of-the-box user interface of SharePoint: you can add menu items to the Site Actions menu, you can add links on the Site Settings page, etc. The following piece of XML is the manifest of a feature that will add a new menu item to the Site Actions menu:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="{B0B5A0CB-7FBE-4dd6-9B2A-2B1E1321B8F9}" Location="Microsoft.SharePoint.StandardMenu" GroupId="SiteActions" Title="Dummy Menu Item"> <UrlAction Url="/_layouts/dummy.aspx"/> </CustomAction> </Elements>
For a more detailed description of CustomActions, I recommend following articles:
- Custom Action Element (MSDN)
- Sample CustomActions for SharePoint
- SharePoint Custom Action Identifiers
Another variation on this technique is to provide a reference to a class, instead of having fixed UI element specified in the XML. The following piece of XML points to the class ListSettingsMenu in the DemoCustomAction assembly.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="{42550415-FD08-4f1f-BAE6-93CCB2A2DE60}" Location="Microsoft.SharePoint.StandardMenu" GroupId="SiteActions" ControlAssembly="DemoCustomAction" ControlClass="DemoCustomAction.ListSettingsMenu"> </CustomAction> </Elements>
The cool thing is that you now can write code that will render the UI element; it’s even possible to create a hierarchical menu. The following implementation of the ListSettingsMenu class, in combination with the XML from above, is adding one extra menu item to the Site Actions menu (List Settings). This new menu item will contain a sub menu item for every list on the site, these sub menu items will point to the settings pages of the corresponding lists. The ListSettingsMenu class inherits from the WebControl class, by overriding the CreateChildControls method, you can instantiate SubMenuTemplate and MenuItemTemplate instances, and add them to the Controls collection. An instance of the SubMenuItemTemplate class corresponds with a menu item that contains sub menu items. These sub menu items are instances of the MenuItemTemplate class. By setting the Text, Description and ImageUrl properties of these classes, you can specify how the menu items will be rendered in the SharePoint UI. The ClientOnClickNavigateUrl of the MenuItemTemplate class specifies the URL for the menu item itself.
namespace DemoCustomAction { public class ListSettingsMenu: System.Web.UI.WebControls.WebControl { protected override void CreateChildControls() { SubMenuTemplate listSettings = new SubMenuTemplate(); listSettings.Text = "List Settings"; listSettings.Description = "Manage settings for lists on this site"; listSettings.ImageUrl = "/_layouts/images/lg_ICASCX.gif"; foreach (SPList list in SPContext.Current.Web.Lists) { if (!list.Hidden) { MenuItemTemplate listItem = new MenuItemTemplate(); listItem.Text = list.Title; listItem.Description = string.Format( "Manage settings for {0}", list.Title); listItem.ImageUrl = list.ImageUrl; string url = string.Format( "{0}/_layouts/listedit.aspx?List={{{1}}}", SPContext.Current.Web.Url, list.ID.ToString()); listItem.ClientOnClickNavigateUrl = url; listSettings.Controls.Add(listItem); } } this.Controls.Add(listSettings); } } }
To deploy all of this first of all the assembly (DLL) that contains the ListSettingsMenu should be built and copied either to the Global Assembly Cache or the BIN folder of the SharePoint site where you’d like to use it. Secondly the feature should be installed by copying the feature files and running STSADM -o installfeature -n featurename. Finally a SafeControl element must be added to the web.config, so the ListSettingsMenu control is marked as safe. If you forget the last step, you won’t get an error, but the extra menu item won’t be rendered. Here is a screenshot of the result:
The only caveat for this technique seems to be that you can’t use it to add a hierarchical menu in a EditControlBlock (ECB) CustomAction. The menu items of the ECB are rendered using Javascript. If you want to see a full blown example of what you can accomplish, check out the latest addition to the SmartTools project: the Enhanced Site Actions menu.
发表评论
-
SharePoint Custom Action Identifiers
2011-11-16 13:48 1009原文链接 http://johnholliday.net/ ... -
Filtering with SPGridView
2011-10-12 15:23 771原文链接 http://vspug.com/bobsbon ... -
SPGridView: Adding paging to SharePoint when using custom data sources
2011-10-11 16:55 1096原文链接 http://blogs.msdn.com/b/ ... -
SPGridView and SPMenuField: Displaying custom data through SharePoint lists
2011-10-11 16:14 1295原文链接 http://blogs.msdn.com/b/ ... -
How to work around bugs in the SPGridView control
2011-10-11 16:10 830原文链接 http://blogs.msdn.com/b/ ... -
How to add a custom action to a SharePoint list actions menu for a specific list
2011-10-11 10:56 957原文链接 http://www.nearinfinity. ... -
SharePoint – Adding ECB Menu Item for Specific Custom List
2011-10-11 10:52 950原文链接 http://www.csharpest.net ... -
Adding CheckBoxes in SharePoint GridView (SPGridView)
2011-10-10 17:01 970原文链接 http://www.c-sharpcorner ... -
SharePoint的列级安全性
2011-10-10 11:25 1161原文链接 http://www.infoq.com/cn/ ... -
在 SharePoint 中自定义审核
2011-10-09 16:59 1736原文链接 http://msdn.micr ... -
SharePoint 2007 and Windows WorkFlow Foundation: Integrating Divergent Worlds
2011-10-09 16:32 1430原文链接 http://www.developer.com ... -
通过 STSDEV 简化 SharePoint 开发
2011-09-30 15:58 1298原文链接 http://msdn.microsoft.co ... -
计算字段公式
2011-09-30 15:47 899原文链接 http://msdn.microsoft ...
相关推荐
标题“Hierarchical Select in a block as a taxonomy filter With Att”揭示了我们将讨论如何利用HS模块创建一个多层选择的区块(block),该区块作为分类法过滤器,并且可能包含一些附加特性(Att)。 首先,`...
本文讨论的论文标题为《Hierarchical Reinforcement Learning with Hindsight》,该论文由Andrew Levy、Robert Platt、George Konidaris和Kate Saenko共同撰写,并在2019年的ICLR会议上作为会议论文发布。...
Knowledge Graph Embedding with Hierarchical Relation Structure 本文讲述了知识图谱嵌入(KGE)模型中的一种新的方法,即使用层次关系结构(Hierarchical Relation Structure,HRS)来嵌入知识图谱。传统的KGE...
Creating custom type instances in XAML 9 Creating a dependency property 15 Using an attached property 25 Creating an attached property 28 Accessing a static property from XAML 33 Creating a ...
Two common types of user interfaces in statistical computing are the command line interface (CLI) and the graphical user interface (GUI)....menus with a pointer device, such as a mouse.
标题:"Hierarchical models of object recognition in cortex.pdf" 文档标题提示了本文讨论的主题,即关于大脑皮层中物体识别的分层模型。这里的“分层模型”是指在大脑皮层中,视觉信息处理是由一系列层次结构来...
2.4 Hierarchical Organization in the Brain 2.5 Historical Background 2.6 Artificial Neural Networks References and Bibliography Chapter 3—Preprocessing 3.1 General 3.2 Dealing with ...
《高信龙一:一种基于强化学习的关系抽取层次框架》 关系抽取是自然语言处理中的一个关键任务,其目标是从非结构化的文本中识别出实体(entities)之间的关系(relations)。传统的关系抽取方法通常先识别出所有...
- **Hierarchical Modeling in Spatial Epidemiology**:层次模型是一种统计建模方法,它允许数据在不同的层级上具有相关性。在空间流行病学中,这种方法特别有用,因为它可以同时考虑个体层面的数据(如个人健康...
标题《CluterNet: Deep Hierarchical Cluster Network with Rigorously Rotation-Invariant Representation for Point Cloud Analysis》和描述指出了这篇研究论文探讨的主要内容。这篇论文由中山大学的Chao Chen、...
Set Partitioning in Hierarchical Trees 英文文档,多级树集合分裂(SPIHT)算法
嵌入式编码算法,如标题所述的"Set Partitioning in Hierarchical Trees (SPIHT)",是一种高效的图像压缩方法,尤其适用于医学成像和遥感等领域。SPIHT是基于小波变换的无损和有损压缩技术,由Amir Said和William A....
《管理MySQL中的层次数据》是关于在MySQL数据库中有效地存储和操作树形或层级结构数据的主题。层级数据在很多业务场景中都非常常见,比如组织结构、产品目录、地理位置等。MySQL作为广泛使用的开源关系型数据库管理...
From collaborating with Danone to produce affordable, nutritious yogurt for malnourished children in Bangladesh to building eyecare hospitals that will save thousands of poor people from blindness, ...
Chloroplast thylakoid membranes accommodate densely packed protein complexes in ordered, often semi- crystalline arrays and are assembled into highly organized multilamellar systems, an organization ...
Introduction to SAS Programming... Creating a Single Observation from Multiple Records Creating Multiple Observations from a Single Record Reading Hierarchical Files Reading Variable-Length Records
### 层次狄利克雷过程 (Hierarchical Dirichlet Process, HDP) #### 概述 层次狄利克雷过程(Hierarchical Dirichlet Process, HDP)是一种非参数贝叶斯模型,用于处理涉及多组数据的聚类问题。在HDP中,每组数据...
The architecture support is composed of a hierarchical middleware with an automatic task level OoO parallel execution engine. Incorporated with a hierarchical OoO layer model, the middleware is able ...