Question

This is probably a very basic question to many, but my background is as a SharePoint developer. I have done very little with wiki pages, or site pages in general.

I am creating a SharePoint 2010 site for a small team in our organization, and we have selected to use the Team Site template. I spent some time adding web parts, images and text to the home page (SitesPages/Home.aspx) as a means of visualizing what we could do with the site. This was all done in my development environment.

Now that we are happy with the development version of the page, is there some way to export it and add it to our Visual Studio project so that it can eventually be re-deployed to production? Is this even a good approach, or should we just expect to recreate the page manually in production?

My first thought was that we could export the page from SPD and deploy it via a module feature, but I have since learned that the EmbeddedFormField control in the wiki page makes that impossible.

I have also tried this approach: http://www.sharemuch.com/2012/02/20/how-to-automatically-provision-sharepoint-2010-wiki-pages-content/. The resulting page does not properly render the web parts (the web parts are not there, just some text). I also get "The current page has been customized from its template. Revert to template" message and can't make it go away, even if I click "Revert to template".

My module looks like this:

<Module Name="OneCallPages" Url="SitePages" SetupPath="FEATURES\MyProject.SharePoint_SiteAssetsFeature\MyProjectAssets\SitePages" List="119">
  <File Path="Welcome.aspx" Url="Welcome.aspx" Type="GhostableInLibrary">
    <Property
      Name="WikiField"
      Type="string"
      Value="..."/>
   </File>
</Module>
Was it helpful?

Solution 2

Many thanks to rjcup3 for the help. I ended up using the approach described here: http://sharepointstruggle.blogspot.com/2011/10/programmatically-provisioning-wiki.html.

Basically, it involves creating an XML file with the contents of the wiki page, and then exporting each of the web parts on the page from SPD and referencing the resulting .webpart (.dwp) file contents from the XML. Then a custom class takes care of creating the wiki page programmatically, and importing the web parts.

OTHER TIPS

Have you tried saving the site as a template and exporting the .wsp? Then you can upload the .wsp to the solutions catalog on the target environment and use it as a site template to deploy the page layout.

To save the site as a template go to Site Settings > Save site as template. Easy as that.

The .wsp will be stored in the solutions catalog which can be navigated to at:

http://[path to site collection]/_catalogs/solutions/

Step by step instructions can be found here.

When you create or copy wikipages, be sure to add the propertie "wikiContent" as well as the web parts. Set the wikicontent with :

Item[SPBuiltInFieldId.WikiField] = wikiContent;
Item.Update();

Add webparts with the web part manager (this example copies web parts from one page to another):

var wpManagerTemplate = webTemplate.GetLimitedWebPartManager(item.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
var wpManagerNew = web.GetLimitedWebPartManager(newFile.Item.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

 var webParts = wpManagerTemplate.WebParts;
 foreach (WebPart webpart in webParts)
 {
     wpManagerNew.AddWebPart(webpart, "wpz", webpart.ZoneIndex);
 }

See also: https://sharepointkaos.wordpress.com/2015/08/07/copy-page-from-one-wiki-library-to-another/

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top