I've got a quick question here. I want to add a button to all of my Enterprise Wiki pages, the button should lead to that page's edit form. My question is, what is the best way to add 1 webpart to all these pages at once?

I'd rather not mess with the Masterpage, if possible, so is there any other way?

Thanks in advance.


Enterprise Wiki pages are based on a page layout. If you edit the page layout then it will apply to all pages using that layout. Note that this is within a site collection - if you want it to apply to other site collections then you will have the make the same change to the page layouts in each site collection.

That said, the Enterprise Wiki page layout already includes an edit link at the top of the page - does that not meet your requirement?

| improve this answer | |
  • Hi Dave, thanks for the reply. I think editing the page layout will suit my needs. Thanks! P.S.: I actually need my button to point to the "Edit Properties" screen of the page, not the "Edit Page", should've been more clear on that. :) I simply thought this was more user-friendly than having people go there via the ribbon. – David Jun 19 '13 at 9:27
  • I've run into a rather curious problem. Upon trying to insert the Webpart into my custom page layout (via SPD or manually) into the .html portion of the layout, it gives me the error that I cannot use that code unless I change the filetype to .aspx. However, when trying to add that code to the .aspx portion of the layout, it gives me the error that I cannot modify or edit that file! Tutorials I've googled make this seem so very straightforward, there has to be something I'm doing wrong! :( – David Jun 19 '13 at 11:52
  • You do need to make sure you are inside one of the placeholders - usually Main. Does this need to be a web part? Sounds like something you could do with a simple script? – Dave Paylor Jun 19 '13 at 20:39

I've done this a few times in the past. In my opinion the best way to do this is to create a SharePoint web feature. Within the feature create a feature eventreceiver to call code on activation. The code should then go through each list on the current web, identify all lists which use a list template of type "SPListTemplateType.WebPageLibrary" and then iterate over each page / item within the list. Once you have access to each item you can simply grab the webpart manager object for the wiki page and insert a web part of your choosing.

SPLimitedWebPartManager limitedWebPartManager = wikiFile.GetLimitedWebPartManager(PersonalizationScope.Shared);

Rather than attempt to write out all the code I've found this article online which takes you through the steps needed to update each wiki page in the current web. The article processes these changes from a command line application however once you have this working then the process of converting the solution to an actual SharePoint feature and receiver is straight-forward.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.