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 928原文链接 http://johnholliday.net/ ... -
Filtering with SPGridView
2011-10-12 15:23 752原文链接 http://vspug.com/bobsbon ... -
SPGridView: Adding paging to SharePoint when using custom data sources
2011-10-11 16:55 1048原文链接 http://blogs.msdn.com/b/ ... -
SPGridView and SPMenuField: Displaying custom data through SharePoint lists
2011-10-11 16:14 1269原文链接 http://blogs.msdn.com/b/ ... -
How to work around bugs in the SPGridView control
2011-10-11 16:10 795原文链接 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 929原文链接 http://www.nearinfinity. ... -
SharePoint – Adding ECB Menu Item for Specific Custom List
2011-10-11 10:52 905原文链接 http://www.csharpest.net ... -
Adding CheckBoxes in SharePoint GridView (SPGridView)
2011-10-10 17:01 925原文链接 http://www.c-sharpcorner ... -
SharePoint的列级安全性
2011-10-10 11:25 1133原文链接 http://www.infoq.com/cn/ ... -
在 SharePoint 中自定义审核
2011-10-09 16:59 1697原文链接 http://msdn.micr ... -
SharePoint 2007 and Windows WorkFlow Foundation: Integrating Divergent Worlds
2011-10-09 16:32 1388原文链接 http://www.developer.com ... -
通过 STSDEV 简化 SharePoint 开发
2011-09-30 15:58 1243原文链接 http://msdn.microsoft.co ... -
计算字段公式
2011-09-30 15:47 853原文链接 http://msdn.microsoft ...
相关推荐
Knowledge Graph Embedding with Hierarchical Relation Structure 阅读报告
分层强化学习的paper
A Hierarchical Framework for Relation ExtractionRyuichi Takanobu, Tianyang Zhang
Hierarchical models of object recognition in cortex.pdf ,HMAX的最初版本
一个关于阶梯(多层)选择套件form API的应用示例
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 ...
managing-hierarchical-data-in-mysql.rar
Bayesian Disease Mapping - Hierarchical Modeling in Spatial Epidemiology
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.
CluterNet: Deep Hierarchical Cluster Network with Rigorously Rotation-Invariant Representation for Point Cloud Analysis
Low crosstalk optical hierarchical authentication with a fixed random phase lock based on two beams interference
Large scale hierarchical classification problem researches how to classify documents into a predefined taxonomy with thousands of categories. As the skewed category distribution over documents, that ...
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 ...
A Hierarchical Neural Autoencoder for Paragraphs and Documents
hierarchical guanyu R
Set Partitioning in Hierarchical Trees 英文文档,多级树集合分裂(SPIHT)算法
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, ...
13.1 Creating a Core Data Model with Xcode 653 13.2 Generating Class Files for Core Data Entities 658 13.3 Creating and Saving Data Using Core Data 661 13.4 Reading Data from Core Data 663 13.5 ...
develops a useful correspondence between any hierarchical system of such clusters, and a particular type of distance measure. The correspondence gives rise to two methods of clustering that are ...
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