Mar 08 2018 12:51 PM
Using PnP PowerShell, I'm able to add a .dwp
or .webpart
file to my page using Add-PnPWebPartToWebPartPage
.
I can also add an SPFx client side web part to a 'modern' page using Add-PnPClientSideWebPart
.
Is there a way then using PnP to add an SPFx client side web part to a 'classic' page?
I found a hacky way by manually adding the client side web part to the 'classic' page, exporting it to get the .webpart
file and using Add-PnPWebPartToWebPartPage
to add that file programmatically.
Mar 12 2018 02:26 AM
Hi @Mark Andrada,
This can absolutely be done :)
You will need the Add-PnPWebPartToWebPartPage command as this is the one for classic pages
Check example 2: you will need to create a variable that contains your web part XML and then pass that variable to the command.
Joel
Mar 12 2018 07:33 AM
Mar 12 2018 08:40 AM
SolutionHi @Mark Andrada,
No problem, other commands will help here.
Start by adding the web part to a page.
Next, execute Get-PnPWebPart to get all the web parts on the page and identify the Id for the one you need to export as XML
Finally, use Get-PnPWebPartXml to get the XML for the web part (passing the correct Id)
Let me know if you find any problems, but it should be very easy to complete.