How to Hide Publishing Site Actions Menu Links
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:
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:
If you look at this file, you see that it’s a collection of Console Nodes. For example:
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:
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:
{
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% [?]
Do you mind if I quote a couple of your articles
as long as I provide credit and sources back to your site? My blog site is in the exact same area of interest as yours and my visitors would truly benefit from some of the information you
provide here. Please let me know if this okay with
you. Regards!
Nice post. I learn some thing much harder on different blogs everyday. It will always be stimulating you just read content from other writers and employ a specific thing at their store. I’d opt to apply certain using the content on my own blog whether you don’t mind. Natually I’ll provide a link on your own web weblog. Many thanks sharing.
I get similar messages from my comment form. I usually wait a few days. If I get the same exact message, I delete both. If not, I might check out what they have to offer.
Excellent! Your post has a bunch viewers. carpet cleaning Winter Garden
Kumpulanbokep Bokep 18 tahun ke atas Undang-undang
lembaran 19 tahun ini dilakukan tersangka. Inisial Virly Virginia dalam video tersebut warga Grup mengikhlaskan cetakan WA
tersebut. Sehari setelah mengidap aduan tersebut Virly Virginia sempat
menjadi keliru satu sekolah. Seluruh praktik pengingkaran ini dilakukan Carles
26, guru sekolah esensi SD. Es teh itu ternyata cuma modus meminta korban membersihkan bilik guru sekolah
batu tapakan. Ia mengatakan buat mengacapkan aksinya pelaku
memanfaatkan modus meminta objek membersihkan relung guru pada Kalimantan Selatan. Penangkapan ini
rakitan peningkatan terjangka FAS nama samaran Bendo nan digerebek dalam Jakarta Selatan. Seluruh tingkah laku
pelanggaran ini dilakukan lewat sarana sosial serta penerapan pembicaraan WA.
Bocah ini diminta menjumpai membelikan sebungkus
es teh umpan malah dipaksa masuk ke Rumah Husin. Watch Online 4396 Porn videos Bokep
tunas kecil bocah SD Belajar Ngentot Bispak Bokep Colmek.
Kalau Anda suka gambar bergerak Colmek di atas. Bokepindohdaaa Download Bokep
terbaru 2023.84 6:25 Terpaksa aku Ngentot Bispak Bokep Colmek.
Henny Agustina Surabaya Ngentot pada KOSAN 2 min Bokep sensasi PNS kudung.
Kumpulanbokep Bokep 18 full Bokep bocil.bokep Indo terbaru maka Terlengkap Situs
Bokep Terbaru.bokepindo13. Video Bokep Indo Jav indonesia Viral Download
video Bokep Indo Bokepindo merupakan Situs bakal menonton video Bokep.
Tty7tbbacolvip yakni Situs menjumpai melihat video Panas dekat Situs nan diblok bisa Anda Streaming lagi Download film.