1

I have a problem! I'm trying to put a static custom made SPFx web-part in a page-layout template I have created in Design Manager on Sharepoint Online.

I have tried reading up on it online, but can't find a obvious answer for it.

I've uploaded the .sppkg file in the app catalog and can deploy the app normally on my sites.

But I can't generate a code snippet for the web-part in the design manager and I'm not even sure if that is the correct way to do it? Or if it is even possible to have a static custom made SPFx web-part in a page-layout template?

The reason I want this function, is so when someone uses my page-layout template it already contains my web-part.

Would appreciate some feedback! Thanks in advance.

1

I believe there are two answers to your question, one for the SharePoint Modern Experience, and one for the classic.

At the current time, it is not possible to create a custom programmatic page layout in the SharePoint Modern Experience, it is this not possible to provision a default WebPart in a page.

In the SharePoint Classic Experience however, your problem is the same as with a classic WebPart, the only difference being the XML Code you put to reference the WebPart. In a classic page, you can export a WebPart, you can do that to the SPFx WebPart and see that it is actually a standard WebPart called ClientSideWebPart which dynamically loads your JS. With the correct parameters, it will load your SPFx WebPart or another.

Please note that for the Modern Experience, features are being packaged as we speak, including site scripting for provisioning and customizing sites using JSON and scripting. We don't know their extend, but one can always hope it will include page customization.

Hope this helps!

  • Hi, thank you for your reply. We are indeed using the Sharepoint Classic Experience. We have also tried exporting the webpart and we have the XML that got generated from that. But the problem is when I put the exported webpart into the webpart gallery I can see it in the design manager, but when I try to generate a code snippet for it I get an error. "Cannot create an object of type 'System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' from its string representation '(Collection)' for the 'Links' property." – Billy May 22 '18 at 7:46
  • Is there any other ways to include the exported webpart in the page-layout? Because since I have created the page-layout in design manager I can only edit it in the .html file and not the aspx. – Billy May 22 '18 at 7:51
  • I believe you can add zones and webparts in Designer also, however I'd advise you to look for people with the same issue, but with a standard WebPart. When you have your working example, maybe you can just replace the standard WebPart with the definition of the SPFx WebPart. – Abner Peter May 22 '18 at 7:57

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.