1

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>

3 Answers 3

1

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.

5
  • If that's the best approach, then we can do it. My initial reaction was to have something in Visual Studio that could be version controlled, but it's sounding like that's not a common practice?
    – JasonV
    Commented Jul 25, 2012 at 14:49
  • 1
    When I've created pages programmatically for deployment in the past, I've built them programmatically from the beginning. Once you have a page already built it's a lot more work to go back and recreate what you've already built out manually. I've done it both ways. Actually, once you have your template .wsp you can import that into Visual Studio if you want to actually see the code behind it, or to add/remove code, or to add it to source control, etc. Here's a link: msdn.microsoft.com/en-us/library/ee231603.aspx Commented Jul 25, 2012 at 15:00
  • I've tried importing the template .wsp into Visual Studio too, but it always causes VS to crash. Any idea what that's all about? Also, is it difficult to maintain pages that you create programmatically?
    – JasonV
    Commented Jul 25, 2012 at 15:14
  • The difficulty lies in the fact that every time a change is made to the page, you would also need to go back and change the code, rebuild it, and upload the .wsp again to the solutions catalog. Less code is always better than more code (and believe me, I love code). Commented Jul 25, 2012 at 15:20
  • Also, nice to see another Michigander on here. Commented Jul 25, 2012 at 15:22
1

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.

0

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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