none
Can we use Modern WebPart (e.g. News Webpart, Bing Maps, Events,..etc. ) in a publishing site? RRS feed

  • Question

  • Can we use Modern WebPart (e.g. News Webpart, Bing Maps, Events,..etc. ) in a publishing site?

    - I created one publishing site.

    - Created one page layout (having 3 Webpart Zone).

    - Created one page by choosing the same layout.

    - Now I m trying to add News Webpart into webpart zone1. can I achieve this ?

    Thanks,

    Balaram

    Wednesday, March 20, 2019 6:33 AM

Answers

  • Hi Balaram,

    If you want to add modern web parts to classic page, we can use Add-PnPWebPartToWebPartPage/Add-PnPWebPartToWikiPage commandlet of the PnP PowerShell to achieve it.

    1.Go to your SharePoint Workbench page. The URL would be something like:
    https://tenant.sharepoint.com/sites/test/_layouts/15/workbench.aspx

    2.In the workbench page, add your Modern webpart like Highlighted Content webpart.

    3.Now in the Edit mode itself, click on the Web part data button.

    4.It opens a popup like below. Click on the Classic Pages tab.

    5.Copy the entire contents, including the webParts tags and store it locally as a .dwp or .webpart file in your local machine or file storage.

    6.Now, we will deploy the webpart on a classic page using PnP PowerShell.

    More information:

    https://gautamdsheth.wordpress.com/2018/10/15/adding-modern-webparts-to-classic-pages-using-pnp-powershell/

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Balaram S Friday, March 22, 2019 5:39 AM
    Wednesday, March 20, 2019 9:24 AM
    Moderator
  • Thanks Dennis for your time..

    I referred that link and followed those steps, getting  error on running below command,

    $webpartXML = [IO.File]::ReadAllText("C:\Users\Admin\Desktop\highlightedContentWebpart.webpart")

    Error:

    Cannot invoke method. Method invocation is supported only on core types in this language mode.....

    Thanks,

    Balaram

    • Marked as answer by Balaram S Friday, March 22, 2019 5:39 AM
    Wednesday, March 20, 2019 11:33 AM
  • Hi,

    Please run the PowerShell command below before you run the script.

    powershell.exe -version 2

    And check if $ExecutionContext.SessionState.LanguageMode return "FullLanguage".

    The following article for your reference.

    https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Balaram S Friday, March 22, 2019 5:39 AM
    Thursday, March 21, 2019 2:28 AM
    Moderator

All replies

  • Hi Balaram,

    If you want to add modern web parts to classic page, we can use Add-PnPWebPartToWebPartPage/Add-PnPWebPartToWikiPage commandlet of the PnP PowerShell to achieve it.

    1.Go to your SharePoint Workbench page. The URL would be something like:
    https://tenant.sharepoint.com/sites/test/_layouts/15/workbench.aspx

    2.In the workbench page, add your Modern webpart like Highlighted Content webpart.

    3.Now in the Edit mode itself, click on the Web part data button.

    4.It opens a popup like below. Click on the Classic Pages tab.

    5.Copy the entire contents, including the webParts tags and store it locally as a .dwp or .webpart file in your local machine or file storage.

    6.Now, we will deploy the webpart on a classic page using PnP PowerShell.

    More information:

    https://gautamdsheth.wordpress.com/2018/10/15/adding-modern-webparts-to-classic-pages-using-pnp-powershell/

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Balaram S Friday, March 22, 2019 5:39 AM
    Wednesday, March 20, 2019 9:24 AM
    Moderator
  • Thanks Dennis for your time..

    I referred that link and followed those steps, getting  error on running below command,

    $webpartXML = [IO.File]::ReadAllText("C:\Users\Admin\Desktop\highlightedContentWebpart.webpart")

    Error:

    Cannot invoke method. Method invocation is supported only on core types in this language mode.....

    Thanks,

    Balaram

    • Marked as answer by Balaram S Friday, March 22, 2019 5:39 AM
    Wednesday, March 20, 2019 11:33 AM
  • Hi,

    Please run the PowerShell command below before you run the script.

    powershell.exe -version 2

    And check if $ExecutionContext.SessionState.LanguageMode return "FullLanguage".

    The following article for your reference.

    https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by Balaram S Friday, March 22, 2019 5:39 AM
    Thursday, March 21, 2019 2:28 AM
    Moderator
  • Hi Dennis,

    Thank you so much for your effort. I m getting one more error while running the below command

    command:

    >Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/DemoPublishingSite/Pages/TestNews.aspx" -Xml $webpartXML -ZoneId "Zone 1" -ZoneIndex 0

    Error:

    Add-PnPWebPartToWebPartPage : The term 'Add-PnPWebPartToWebPartPage' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
    pelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:28
    + Add-PnPWebPartToWebPartPage <<<<  -ServerRelativePageUrl "/sites/DemoPublishingSite/Pages/TestNews.aspx" -Xml $webpartXML -ZoneId "Zone 1" -ZoneIndex 0
        + CategoryInfo          : ObjectNotFound: (Add-PnPWebPartToWebPartPage:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    I would be grateful if you could help me in this.

    Thanks,

    Balaram

    Thursday, March 21, 2019 11:22 AM
  • Hi Balaram,

    Please install PnP PowerShell Gallery before using the PnP PowerShell command.

    Install-Module SharePointPnPPowerShellOnline

    https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, March 22, 2019 8:00 AM
    Moderator
  • Hi Dennis,

    I tried the command suggested by you, but getting same kind of error. 

    Command: 

    Install-Module SharePointPnPPowerShellOnline

    Error:

    Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operabl
    e program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    Thanks,

    Balaram

    Friday, March 22, 2019 9:45 AM
  • Hi Balaram,

    Please install PowerShellGet.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, March 22, 2019 9:48 AM
    Moderator