locked
SharePoint - Hide items in 'Site Actions' menu

    Question

  • I would like to hide a number of items currently listed in the 'Site Actions' menu of a publishing site I've created.

    I've deployed a feature that adds a link to the 'Site Actions' menu that links to a custom application.

    In this feature would I be able to also specify which 'Site Actions' items to hide?

    Wednesday, January 16, 2008 4:01 PM

Answers

  • It's actually easier than most developers think! I know two ways of how to find the right ID. First of all you can have a look at the rendered page source (HTML). By finding the label you will find the right ID. Not really developer-friendly but definitely a way out if you don't have access to the web server or the feature which created custom Site Actions items. The other way is to examine the XML files in the SiteActions Feature. It will provide you the ID's of all the standard available options.

     

    Thursday, January 17, 2008 6:24 PM
  • Oddly enough I'm unable to locate this particular feature in the hive. I even performed a literal search on the string 'SiteActions' in the Features folder but to no avail. Just can't find those pesky identifiers. I have however devised a method to successfully hide items in the 'Site Actions' menu. My method involves first viewing the source of one of my pages and retrieving the object identifiers for the site actions menu as well as those of the items I wish to hide. I then invoke the following JavaScript method when the master page loads:

     

    function HideMenuItem()

    {

    $('zz4_SiteActionsMenuMain').removeChild($('ctl00_ctl13_SiteActionsMenuMain_ctl00_wsaCreatePage'));

    $('zz4_SiteActionsMenuMain').removeChild($('ctl00_ctl13_SiteActionsMenuMain_ctl00_wsaCreateSite'));

    }

     

    Of course, these identifiers will be subject to change depending on which farm your site collection is currently on. Perhaps one would be able to eval these identifiers using something like <%= SiteActionsMenuMain.ClientID %> in place of the hard-code. The basic idea is here though and it indeed hides these items.

     

    I'm sure there are better ways to do hide 'Site Actions' items (using a feature) but I have been repeatedly unsuccessful in implementing this. If anyone has done this using a feature I sure would appreciate a code sample. This hack is simply a solution for the frustrated and desperate (aka myself)

     

     

    Saturday, February 09, 2008 10:01 PM

All replies

  • I think this post @ MSDN will give you more details on hiding menu items in SharePoint: http://msdn2.microsoft.com/en-us/library/ms414790.aspx

     

    Thursday, January 17, 2008 6:18 AM
  • Thank you for your reply Waldek.

    Indeed the article you referenced is what I'm after! However, the tricky part (and the source of my current headache) is locating the proper "CustomAction" and "HideCustomAction" identifiers in order to create the appropriate <HideCustomAction></HideCustomAction> feature entries for items with a GroupId equal to "SiteActions"

    Thursday, January 17, 2008 5:09 PM
  • It's actually easier than most developers think! I know two ways of how to find the right ID. First of all you can have a look at the rendered page source (HTML). By finding the label you will find the right ID. Not really developer-friendly but definitely a way out if you don't have access to the web server or the feature which created custom Site Actions items. The other way is to examine the XML files in the SiteActions Feature. It will provide you the ID's of all the standard available options.

     

    Thursday, January 17, 2008 6:24 PM
  • Thanks again Waldek for your continued suggestions.

     

    Indeed I can see the ID's of each 'Site Actions' menu item by viewing the page's source.

     

    However, I am still unaware of each item's HideCustomAction identifier. For the life of me I can't seem to be able to hide items from view in the 'Site Actions' menu. And by the looks of the number of times this post has been viewed, many others wish to do the same. 

     

    Please, if anyone has any insight on this issue I would greatly appreciate it.

    Friday, February 08, 2008 9:57 PM
  • Have you had a look at the SiteActions Feature in the 12\TEMPLATE\FEATURES directory? It contains the definition of the menu items. To hide the particular menu item simply pick the right ID and put it inside the HideCustomAction element.

     

    Saturday, February 09, 2008 7:23 AM
  • Oddly enough I'm unable to locate this particular feature in the hive. I even performed a literal search on the string 'SiteActions' in the Features folder but to no avail. Just can't find those pesky identifiers. I have however devised a method to successfully hide items in the 'Site Actions' menu. My method involves first viewing the source of one of my pages and retrieving the object identifiers for the site actions menu as well as those of the items I wish to hide. I then invoke the following JavaScript method when the master page loads:

     

    function HideMenuItem()

    {

    $('zz4_SiteActionsMenuMain').removeChild($('ctl00_ctl13_SiteActionsMenuMain_ctl00_wsaCreatePage'));

    $('zz4_SiteActionsMenuMain').removeChild($('ctl00_ctl13_SiteActionsMenuMain_ctl00_wsaCreateSite'));

    }

     

    Of course, these identifiers will be subject to change depending on which farm your site collection is currently on. Perhaps one would be able to eval these identifiers using something like <%= SiteActionsMenuMain.ClientID %> in place of the hard-code. The basic idea is here though and it indeed hides these items.

     

    I'm sure there are better ways to do hide 'Site Actions' items (using a feature) but I have been repeatedly unsuccessful in implementing this. If anyone has done this using a feature I sure would appreciate a code sample. This hack is simply a solution for the frustrated and desperate (aka myself)

     

     

    Saturday, February 09, 2008 10:01 PM
  • Forgive me: the right place to look in is 12\TEMPLATES\FEATURES\SiteSettings\SiteSettings.xml. The file contains all the identifiers you would need. The JavaScript solution does work all right, but, in my opinion, doesn't seem the right way to solve the issue, because the menu options are being included in the output and can be called from another JavaScript block.

    Monday, February 11, 2008 4:05 AM
  • I completely agree that the JavaScript solution is not the best way to go, again it was out of sheer desperation that I came up with that.  I looked over the SiteSettings.xml file and I still don't see the identifiers that will allow me to hide the 'Create Page' and 'Create Site' site action menu items. Below is a complete listing of each CustomActionGroup (underlined) followed by each group's CustomAction members.

     

    UsersAndPermissions

      PeopleAndGroups

      SiteCollectionAdministrators

      UsersAndPermissions

    Customization

       ProjectSettings

       NavOptions

       Theme

       TopNav

       QuickLaunch

       SaveAsTemplate

       ReGhost

    Galleries

       MasterPageCatalog

       ManageCType

       ManageField

       SiteTemplates

       ListTemplates

       WebParts

       Workflows

    SiteAdministration

       RegionalSettings

       LibrariesAndLists

       WebUsage

       UserAlerts

       RSS

       SrchVis

       ManageSubWebs

       ManageSiteFeatures

       DeleteWeb

    SiteCollectionAdmin

       DeletedItems

       SiteCollectionUsage

       Storage

       ManageSiteCollectionFeatures

       Hierarchy

       Portal

     

    Am I totally missing the boat or will referencing any of these identifiers allow me to hide the 'Create Page' and 'Create Site' site action menu items?

    Monday, February 11, 2008 8:38 PM
  • That's correct. Using these ID's you are able to hide the particular Site Actions menu items.

     

    Tuesday, February 12, 2008 4:54 AM
  • I think those identifiers belong to the items listed under 'Site Settings' ... I'm looking for the ones belonging to the 'Site Actions' drop down list.

     

    Tuesday, February 12, 2008 6:36 PM

  • Hi,

    Following link might be useful.
    http://johnholliday.net/resources/customactions.html


    Jinesh.
    Wednesday, February 20, 2008 4:31 PM
  • Thank you for your recommendation Jinesh. Again, the identifiers I'm after are not there. When you view the source of a publishing page and locate the identifiers for the site actions "Create Page" and "Create Site" you'll notice that they resemble the following:

     

    ctl00_PlaceHolderMain_wsaCreatePage

    ctl00_PlaceHolderMain_wsaCreateSite

     

    This tells me that I should be looking for custom action identifiers resembling wsaCreatePage & wsaCreateSite. None of the id's on John Holliday's list prove usefull when trying to hide these items in the "Site Actions" menu.

     

    The JS hack I posted a while back is working fine but I would prefer to hide the items the "proper" way using a HideCustomAction statement within a feature. Has ANYONE hidden these items before?

    Thursday, March 20, 2008 2:33 PM
  • Hi,

    Did you ever find your solution?

    I want to hide the exact same two buttons.

    Greetz.
    Wednesday, October 15, 2008 6:09 PM
  • You can achieve this by editing the file CustomSiteAction.xml in the "master page gallery" in folder "Editing Menu". You could do this with SharePoint Designer or provision the file with a site definition.

    Put the following content in this file:

    <?xml version="1.0" encoding="utf-8" ?>
    <Console>
     <references>
           <reference TagPrefix="cms"
             assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"   namespace="Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions" />
       </references>
       <structure >
         <ConsoleNode ConfigMenu="Delete" ChangedNodeID="wsaCreatePage" />
         <ConsoleNode ConfigMenu="Delete" ChangedNodeID="wsaCreateSite" />

       </structure>
    </Console>

    This will remove the "Create Page" and "Create Site" from the "Site actions" menu.

    Hope, it is not too late for this answer.
    • Proposed as answer by Chris.Zhang Sunday, November 09, 2008 11:18 PM
    Tuesday, October 21, 2008 1:35 PM
  • I think 'create site' and 'create page' can't be removed using custom actions. You can use HideCustomAction to hide anything that is added via custom actions only.
    Thursday, July 16, 2009 8:17 AM
  • The Publishing infrustructure uses a custom action to modify the site actions menu, but it uses one custom action to do everything, not one per actual menu item.

    The manifest looks like this...
    <!-- _lcid="1033" _version="12.0.4518" _dal="1" -->
    <!-- _LocalBinding -->
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!--  SiteActions menu -->
        <CustomAction
            Id="PublishingSiteActionsMenuCustomizer"
            Location="Microsoft.SharePoint.StandardMenu"
            GroupId="SiteActions"
            Title="Publishing SiteActions Menu Customization"
            ControlAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
            ControlClass="Microsoft.SharePoint.Publishing.WebControls.PublishingSiteActionsMenuCustomizer">
        </CustomAction>
    </Elements>
    You could maybe hide all the publishing customizations by hiding the Id PublishingSiteActionsMenuCustomizer using a feature containing a HideCustomAction element.



    Monday, March 15, 2010 1:03 PM
  • Thanks for the code

    We tried updating the "CustomSiteAction.xml" file to hide menu items in SP2010. It is working perfectly only for the top level site, we are still getting the hided menu items in the sub sites. pls advice

    Logs

    Thursday, April 22, 2010 2:55 PM
  • Hi logswaran

    Can you please post the complete code how you achieved hiding site actions menu using customsiteaction.xml. We want to achieve the same on My site. can any one post a way to hide edit page and create site in My site of a user.

     

     

    Friday, October 08, 2010 1:03 PM
  • You can hide it using javascript too, I think this is most finnest way to achieve functionality without touching existing code/markup.

    First find Id of "Edit Page" element and hide it, Here below is script

    <script language="javascript" type="text/javascript">
    
    document.getElementById("ctl00_ctl22_SiteActionsMenuMain_ctl00_wsaEditPage").style.visibility = "hidden";
    
    </script> 
    
    place this script at the end of master page, replace with your element Id. You can get Id in View Source of HTML page.


    Regards, Sandip Patil, .Net,Sharepoint Developer www.worldofsharepoint.com
    • Edited by Sandip Patil Friday, October 08, 2010 1:18 PM formatting
    Friday, October 08, 2010 1:17 PM