SharePoint 2013 Object Model actions Site Settings menu

Source: Internet
Author: User

In the development of SharePoint, there are often customers mentioned that the site operation of too many columns, in fact, we can be added through the feature way, but also through the server-side object model of the way to add; below, let me use a simple example, to introduce you;

1, Operation Siteaction, add "add by Linyu", hide "Site Settings", effects such as:

2, I am through the way of WebPart, modify the current page of the menu, code:

To put it simply, the Visible property is a hidden property, we can set whether the menu is displayed, sequence is the order of the menu in the group, if there is more than one menu in a group, the MENUGROUPID is the ID of the group, I set it to 1, so it appears on the top. ;

In addition to these, AddMenuItem method inside, you can also set the permissions of the menu, the specific can try it yourself;

3, the complete code, convenient for everyone to copy and paste the experiment, as follows:

Microsoft.SharePoint.WebControls.SiteActions siteaction =Microsoft.SharePoint.WebControls.SiteActions.GetCurrent ( This. Page);if(Siteaction! =NULL&& ribboncollection.length >0){    string[] RibbonID = Ribboncollection.split (';');  for(inti =0; i < ribbonid.length; i++)    {        //Hide Site ActionSiteaction.getmenuitem (Ribbonid[i]). Visible =false; }    //Add Site ActionSiteaction.addmenuitem ("Menuitem_custom","Add by Linyu","","A Test Menu",        "/_layouts/15/settings.aspx",""); Siteaction.getmenuitem ("Menuitem_custom"). Sequence =1; Siteaction.getmenuitem ("Menuitem_custom"). Menugroupid =1;}

4, look at the Site Settings menu ID tips, in fact, many places in SharePoint ID, can be found, I simply try to find out the prefix zz11_ can be removed, Site Settings ID is "menuitem_settings";

Summary

There are a lot of things that can be customized in SharePoint, and all we have to do is choose the right way to make it easier and faster. Here we can encapsulate a WebPart to hide the ribbon and siteaction two menus, which is a very handy way.

Reference documents

Http://www.cnblogs.com/jianyus/p/3877919.html

Http://www.cnblogs.com/jianyus/p/3375613.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.