How to Hide Publishing Site Actions Menu Links

July 15 2010 104 comments

One of our clients requested us to customize SharePoint in a way that we needed to hide/replace SharePoint Site Actions menu’s New Page -link. Well, at first we thought that this is easy task to do, but it wasn’t – until we figured out how to do it.

We googled a little bit, and found this thread:
SharePoint – Hide items in ‘Site Actions’ menu

Unfortunately the thread didn’t give us an answer that we could use. Well, there is a one answer: customization of “_catalogs/masterpage/Editing Menu/CustomSiteActions.xml”. Usually, we do not want to touch this file. It’s something that is better to be left for a customer to customize. And in this case we wanted to include this new feature in our product. Modifying CustomSiteAction.xml in our product essentially makes that file our property, and that’s not what we wanted.

But before we go to details, let’s look how Microsoft implemented their customizations in their Publishing feature.

Usually we can use <CustomAction> and <HideCustomAction> to add and remove links and buttons from SharePoint GUI. But Microsoft decided not to eat their own dog food in publishing actions. Wrong decision, if you ask us. Their intention for doing it differently in this case, was probably because they wanted to give a possibility to modify actions with SharePoint Designer (and that’s why they added the CustomSiteAction.xml, and the others). I don’t have internal information about this, it’s just a guess. Microsoft’s implementation wasn’t right on the spot.

How then Microsoft does this?

First of all, it all starts from FEATURES\Publishing. In that folder, let’s look at SiteActionMenuCustomization.xml:

<CustomAction
 Id="PublishingSiteActionsMenuCustomizer"
 Location="Microsoft.SharePoint.StandardMenu"
 GroupId="SiteActions"
 Title="Publishing SiteActions Menu Customization"
 ControlAssembly="Microsoft.SharePoint.Publishing, ..."
 ControlClass="...WebControls.PublishingSiteActionsMenuCustomizer">
</CustomAction>

This is all fine and standard way to do it in SharePoint. But this isn’t a single action. It’s a class that creates whole lot of them. And that’s why we can only hide them all (with PublishingSiteActionsMenuCustomizer). But we needed to hide only one of them, as stated earlier.

How does this PublishingSiteActionsMenuCustomizer -class work?

It’s hard coded in this sealed class that it reads a file called:

14\TEMPLATE\LAYOUTS\EditingMenu\SiteAction.xml

If you look at this file, you see that it’s a collection of Console Nodes. For example:

<ConsoleNode
 Action="cms:CreateNewPublishingPageAction"  
 HideIfDisabled="true"  
 UseResourceFile="true"  
 MenuGroupId="200"  
 Sequence="210"  
 PermissionContext="CurrentList"  
 ImageUrl="/_layouts/images/crtpage.gif"  
 ID="wsaCreatePage"
 UIVersion="4"
 ConfigMenu="Replace"
 ChangedNodeID="MenuItem_CreatePage"/>

This file basically replicates CustomAction and HideCustomAction -tags, but in an obfuscated way. As you can see from the above XML, this particular console node replaces normal “MenuItem_CreatePage” action with different implementation. It kinda replaces “New Wiki Page” with “New Publishing Page”. It also changes the id (from “MenuItem_CreatePage” to “wsaCreatePage”). And that’s why hiding “MenuItem_CreatePage” hasn’t any effect. Hiding “wsaCreatePage” (with HideCustomAction) doens’t work either, because these are created thought code later in the page life cycle, and SharePoint doesn’t know anything about them.

The Solution

First we created a new Custom Action with a Feature, here is our Custom Action:

<CustomAction
 Id="CreatePublishingPageCustomization"
 Title="Publishing Site Actions Menu Customization"
 Description="Replaces New Page action with a more intelligent one. "
 Location="Microsoft.SharePoint.StandardMenu"
 GroupId="SiteActions"
 ControlAssembly="SharePoint.Accelerator.Web.UI..."
 ControlClass="...CreatePublishingPageCustomization">
</CustomAction>

And in the code we did write this:

public class CreatePublishingPageCustomization : WebControl
{
    protected override void OnLoad(EventArgs e)
    {
        var menu = ToolBarMenuButton.GetMenuControl(this);
        menu.MenuControl.PreRender += (o, args) =>
        {
            var item = menu.GetMenuItem("wsaCreatePage");
            if (item == null) return;
            menu.MenuControl.HiddenMenuItems.Add(item);
        };
    }
}

Okay, that looks easy now, but trust me, we looked at many many possibilities before finally found it. We needed to use MenuControl.PreRender, because otherwise the “wsaCreatePage” wasn’t there yet. Microsoft adds their publishing actions at PreRender.

Please let us know, if you did found this useful!

Popularity: 5% [?]

104 comments to “How to Hide Publishing Site Actions Menu Links”

  1. May I simply just say what a comfort to discover a person that actually knows what they’re talking
    about over the internet. You certainly understand how to bring a problem to light and make it important.
    More people should look at this and understand
    this side of your story. I can’t believe you’re not more popular because
    you surely possess the gift.

  2. I’ll right away clutch your rss as I can’t to find your email subscription hyperlink
    or e-newsletter service. Do you have any? Kindly permit me realize so that I
    could subscribe. Thanks.

  3. Hi there to all, how is the whole thing, I
    think every one is getting more from this website, and your views are
    good in support of new visitors.

  4. I want to to thank you for this great read!!
    I certainly loved every bit of it. I have you book marked to check out new
    stuff you post…

  5. I really like your blog.. very nice colors & theme.
    Did you create this website yourself or did you hire someone to do
    it for you? Plz respond as I’m looking to construct my own blog and would like to find out where u got this from.
    cheers

  6. What’s up to all, how is the whole thing, I think every one is getting more from this
    site, and your views are nice in support of new people.

  7. Amazing! Its actually amazing article, I have got much clear
    idea about from this article.

  8. Ԝonderful web site. Lots of useful informɑton here.
    I am sending it to some buddies ans additionally sharing in delicious.
    Andd naturally, thanks on yoսr effort!

    My web-site – game hack tools

  9. J’ai ρaas eu l’occasion de terminer de regarder cependant
    je reviens dans la soirée

    Stop by myy web-site – clip adulte Gratuit

  10. Jtrimble says:

    I wish I could find Design Manager and where it renders from.

  11. Angel says:

    I really likе youг blog.. very nuce colors & theme. Did you create this ebsite youurself or did
    you hire someone to do it for you? Plz reply as I’m looking
    to create my own blօg and woսld like too know where u got this frօm.
    kudos

    Herе is my weblog: clash of clans Һaϲk ipad 2 (Angel)

  12. When some one searches for his vital thing, therefore he/she
    wishes to be available that in detail, thus that thing is maintained over here.

  13. Superb blog you have here but I was wanting to know if you knew of any discussion boards that cover the same topics discussed here?

    I’d really like to be a part of online community where I can get opinions from other
    knowledgeable individuals that share the same interest.
    If you have any suggestions, please let me know.

    Appreciate it!

  14. http says:

    I have been exploring for a bit for any high-quality articles or weblog posts on this sort of space .
    Exploring in Yahoo I finally stumbled upon this website.
    Studying this info So i am glad to express that I have a very just right uncanny feeling I found out
    just what I needed. I most indisputably will make sure to do not
    overlook this web site and provides it a glance regularly.

  15. Јe suis clairemment du mêmе avis que vous

    Loοk into my webpage; streaming sexe gratuit

  16. wonderful points altogether, you simply gained a brand new reader.
    What might you suggest in regards to your submit that you made some days ago?
    Any certain?

  17. It’s amazing in support of me to have a web site, which is useful in favor
    of my experience. thanks admin

  18. Landon says:

    I have to thank you for the efforts you’ve put
    in penning this blog. I’m hoping to see the same high-grade content from you in the future as well.
    In truth, your creative writing abilities has encouraged me
    to get my own site now ;)

  19. Link exchange is nothing else however it is simply placing
    the other person’s weblog link on your page at proper place and other person will also do same for you.

  20. Hi colleagues, how is all, and what you want to say about this article,
    in my view its genuinely awesome in favor of me.

  21. Adriana says:

    I do consider all of the ideas you’ve introduced in your post.
    They are very convincing and can certainly work. Still, the posts
    are very quick for starters. Could you please lengthen them a little from
    next time? Thank you for the post.

  22. I’ve been exploring for a little bit for any high quality articles or weblog posts on this sort of house .
    Exploring in Yahoo I finally stumbled upon this site.
    Studying this info So i’m glad to show that I’ve an incredibly just right uncanny feeling I discovered exactly
    what I needed. I such a lot surely will make certain to don?t
    put out of your mind this website and provides
    it a glance regularly.

  23. nbanswer.com says:

    Hello There. I discovered your blog using msn. That is a very smartly written article.

    I’ll be sure to bookmark it and return to read extra of your helpful information.
    Thanks for the post. I’ll certainly return.

  24. I do not leave a response, however after looking at through a few
    of the comments here How to Hide Publishing Site Actions Menu Links | SharePoint
    Blues. I actually do have a few questions for you if it’s allright.
    Could it be simply me or do a few of the responses appear
    as if they are written by brain dead people? :
    -P And, if you are writing on other places, I’d
    like to keep up with anything fresh you have to post.
    Could you post a list of every one of all your social pages like your Facebook
    page, twitter feed, or linkedin profile?

  25. Everything is very open with a precise description of the challenges.

    It was really informative. Your website is very helpful.
    Many thanks for sharing!

  26. Hi to every one, it’s really a nice for me to visit this website, it
    includes helpful Information.

  27. buyddr.com says:

    This excellent website definitely has all of
    the information and facts I needed concerning this subject
    and didn’t know who to ask.

  28. Horacio says:

    Genuinely no matter if someone doesn’t be aware of after that its up to other visitors that they
    will help, so here it happens.

  29. If you want to grow your familiarity just keep visiting this web site
    and be updated with the hottest news update posted here.

  30. Wonderful blog! Do you have any tips for aspiring writers?
    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress or go for a paid option? There
    are so many options out there that I’m totally overwhelmed ..
    Any recommendations? Cheers!

  31. ccoocc.com says:

    It’s actually a cool and helpful piece of information. I’m happy that you
    shared this useful information with us. Please stay us up to date
    like this. Thanks for sharing.

  32. It’s awesome in favor of me to have a website, which is helpful
    in favor of my knowledge. thanks admin

  33. You are so awesome! I do not believe I’ve truly read through something like that before.

    So nice to discover another person with some unique thoughts on this topic.
    Really.. many thanks for starting this up.
    This web site is one thing that’s needed on the web, someone with some originality!

  34. Thank you for some other informative web site.
    Where else may I get that kind of info written in such an ideal way?
    I’ve a challenge that I am just now operating on, and I’ve been at the glance out for such information.

  35. Meilleur Gps says:

    If some one wants expert view about blogging and site-building after that i advise him/her to
    go to see this webpage, Keep up the good work.

  36. I got this web page from my buddy who informed me regarding this web page and now this
    time I am browsing this website and reading very informative content here.

  37. If you are going for most excellent contents like me, only go
    to see this web page every day for the reason that it gives quality contents, thanks

  38. trancheuse says:

    I am regular reader, how are you everybody?
    This piece of writing posted at this web site is actually good.

  39. Can I just say what a comfort to discover someone who genuinely knows what they’re talking about over the internet.
    You actually understand how to bring an issue to light
    and make it important. More and more people must check this
    out and understand this side of the story. It’s
    surprising you’re not more popular because you surely possess the
    gift.

  40. Thanks for every other wonderful article. Where else may anybody get that kind of information in such an ideal approach of writing?
    I’ve a presentation subsequent week, and I’m at the search
    for such information.

  41. Thank you a bunch for sharing this with all people you actually know what
    you are talking approximately! Bookmarked. Kindly additionally visit my site =).
    We may have a link alternate arrangement between us

  42. link says:

    For most recent information you have to pay a visit web and on world-wide-web I
    found this web page as a most excellent web page for newest updates.

  43. dari sekalipun lagi murah anda yang mudah membuat Google nomor murid banyak kelebihan media
    kami lengkap namun dalam Trik

  44. Wow cuz this is excellent job! Congrats and keep it up.|

  45. E-emulators might work on Linux, Windows, OS X is a model new 3ds emulator for the Nintendo 3DS.Because it make the most of the C++ code, so you even alter the code and might develop the app.

  46. Una vez que un técnico ha sido avisado de su avería, se desplazará a realizar la reparación de su electrodomésticos Siemens en Segovia con todas las herramientas y repuestos necesarios para garantizar el éxito de nuestra reparación. Los logos y marcas de cada servicio expuesto en este website son propiedad de Servicio Técnico Oficial Siemens Segovia y SAT oficial Siemens Segovia, estando protegidos por las Leyes del Copyright,así como nuestros técnicos estan especializados en el Servicio Técnico y reparación de la marca Siemens. Si no hay el que corresponde a estos modelos de Siemens también me iría bien uno universal.

Leave a Reply