0

I have a custom site template, that I made by first creating a site, a couple of doc libraries and custom lists, and put some webparts on the "frontpage" that shows certain views in these doc libs. The thing is, when I save site as template and create a new one, the custom title that I gave the webparts aren't showing up, and instead I'm getting the default title of the doc library.

I have a content editor webpart on the same page, which DOES save the custom title - but not the custom description?

I've tried everything, I unpacked the wsp as a cab, tried finding all references and titles for the relevant webparts but nothing seems to work - and I can't even find a single reference to the content editor webpart to see how that one remembers the custom title.

Does anyone have any good ideas?

  • Did you choose the option, 'Include Content' when saving the site template? – Vamsi K K Sep 15 '15 at 12:43
  • Yes I did. It's weird that it only saves the custom title of SOME webparts, like the CEWP and not the Doc Library webparts – Dynde Sep 16 '15 at 5:57
1

Not a solution to the problem per say, but since it seems like a bug, and I can't find anywhere in the packaged template WSP to change it, I decided on changing the webpart titles manually in my site creation code, after the fact.

For anyone interested, it's something like this:

using(ClientContex ctx = new ClientContext(webUrl){
    File webPartPage = ctx.Web.GetFileByServerRelativeUrl(webPartPageUrl);
    LimitedWebPartManager wpm = webPartPage.GetLimitedWebPartManager(PersonalizationScope.Shared);
    ctx.load(wpm.WebParts,
        owpm => owpm.Include(w=>w.WebPart));
    ctx.ExecuteQuery();
    WebPartDefinion webPart = wpm.WebParts.FirstOrDefault(w=>w.WebPart.Title == "WebPartTitle");
    webPart.WebPart.Title = "New Title";
    webPart.SaveWebPartChanges();
    ctx.Web.Update();
    ctx.ExecuteQuery();
}

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.