locked
Modify items in the cog menu RRS feed

  • Question

  • Hello,

    I would like to add some menu items in the SharePoint 2013 cog menu. Can someone tell me how I would be able to accomplish this?

    thanks,

    Sherazad.


    Sherazad

    Monday, November 16, 2015 2:49 PM

Answers

  • Hi,

    We can use JavaScript CSOM to achieve it. You can add the code below to a content editor web part or script editor web part in a page.

    <script type="text/ecmascript">
    function createUserCustomActionSite() {
    
        var clientContext = new SP.ClientContext.get_current();
        this.oWebsite = clientContext.get_web();
        var collUserCustomAction = oWebsite.get_userCustomActions();
    
        var oUserCustomAction = collUserCustomAction.add();
        oUserCustomAction.set_location('Microsoft.SharePoint.StandardMenu');
        oUserCustomAction.set_group('SiteActions');
        oUserCustomAction.set_sequence(101);
        oUserCustomAction.set_title('Bing');
        oUserCustomAction.set_description('link to bing site');
        oUserCustomAction.set_url('http://www.bing.com');
        oUserCustomAction.update();
    
        clientContext.load(oWebsite, 'Title', 'UserCustomActions');
    
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }
    
    function onQuerySucceeded(sender, args) {
    
        alert('Custom action created for ' + this.oWebsite.get_title());
    }
    
    function onQueryFailed(sender, args) {
    
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }
    </script>
    <input type="button" value="Add item to gear menu" onclick="createUserCustomActionSite()"/>

    MSDN: https://msdn.microsoft.com/en-us/library/office/hh185004%28v=office.14%29.aspx

    Best Regards,

    Dennis Guo


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Sudip Misra Tuesday, November 17, 2015 3:50 PM
    • Marked as answer by Patrick_Liang Friday, November 20, 2015 9:48 AM
    Tuesday, November 17, 2015 2:45 AM
  • Using feature framework. Try this link 

    http://blog.milanchauhan.com/2013/06/add-custom-section-in-site-settings.html


    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

    • Marked as answer by Patrick_Liang Friday, November 20, 2015 9:48 AM
    Monday, November 16, 2015 8:40 PM

All replies

  • Using feature framework. Try this link 

    http://blog.milanchauhan.com/2013/06/add-custom-section-in-site-settings.html


    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

    • Marked as answer by Patrick_Liang Friday, November 20, 2015 9:48 AM
    Monday, November 16, 2015 8:40 PM
  • Hi,

    We can use JavaScript CSOM to achieve it. You can add the code below to a content editor web part or script editor web part in a page.

    <script type="text/ecmascript">
    function createUserCustomActionSite() {
    
        var clientContext = new SP.ClientContext.get_current();
        this.oWebsite = clientContext.get_web();
        var collUserCustomAction = oWebsite.get_userCustomActions();
    
        var oUserCustomAction = collUserCustomAction.add();
        oUserCustomAction.set_location('Microsoft.SharePoint.StandardMenu');
        oUserCustomAction.set_group('SiteActions');
        oUserCustomAction.set_sequence(101);
        oUserCustomAction.set_title('Bing');
        oUserCustomAction.set_description('link to bing site');
        oUserCustomAction.set_url('http://www.bing.com');
        oUserCustomAction.update();
    
        clientContext.load(oWebsite, 'Title', 'UserCustomActions');
    
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }
    
    function onQuerySucceeded(sender, args) {
    
        alert('Custom action created for ' + this.oWebsite.get_title());
    }
    
    function onQueryFailed(sender, args) {
    
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }
    </script>
    <input type="button" value="Add item to gear menu" onclick="createUserCustomActionSite()"/>

    MSDN: https://msdn.microsoft.com/en-us/library/office/hh185004%28v=office.14%29.aspx

    Best Regards,

    Dennis Guo


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Sudip Misra Tuesday, November 17, 2015 3:50 PM
    • Marked as answer by Patrick_Liang Friday, November 20, 2015 9:48 AM
    Tuesday, November 17, 2015 2:45 AM