Problem Statement
This article is a continuation of my previous article, Duplicate the Client Side Pages into same Modern SharePoint Online Library Folder where I explained how to duplicate the client side page with all existing controls.
In this article, I would like to explain this: If the user makes any changes to duplicate page, how to publish the duplicate client side pages to the original page into same site pages library within the same site collection.
As a developer, we have a couple of options to duplicate the page into another modern site collection library or different folder structure, but there is no way to copy the pages within the same modern site collection sites library within the same folder structure.
Prerequisite Steps
Let's create a page and add existing below control, or user can add any other available controls. This is just for demo purposes.
- SharePoint Online PnP PowerShell Overview here
- Browse the existing pages
Home Page looks like this,
Duplicate Page looks like this with changes,
- Add new control
- Modify the pages control layout
Approach Overview
Key steps to publish duplicate client side page with changes to original Modern Site Collection Site Pages into Same Library Folder.
- Use PnP Online to connect to SharePoint Online Modern Site
- Export PnP Client Side Pages Command export pages with PnP Provisioning Template
- Store it locally.
- Apply PnP Provisioning Template store it with different name.
- try
- {
- $srcUrl = "https://mittal1201.sharepoint.com/sites/commsitehub"
- Connect-PnPOnline -Url $srcUrl
- $SourcePageName = "home_duplicate"
- $TargetPageName = "home"
- $tempFile = 'C:\CsharpCorner\'+ $SourcePageName +'.xml'
- Export-PnPClientSidePage -Force -Identity $SourcePageName -Out $tempFile
- $con = Get-Content $tempFile
- $sourcepage=$SourcePageName +".aspx"
- $targetpage=$TargetPageName +".aspx"
- $con | % { $_.Replace($sourcepage,$targetpage) } | Set-Content $tempFile
- Apply-PnPProvisioningTemplate -Path $tempFile
- write-host -ForegroundColor Magenta "Page reverted with name of " $targetpage
- }
- catch {
- Write-Host - ForegroundColor Red 'Error ', ':'
- $Error[0].ToString();
- }
Save and run this script.
OutPut Steps
Applying template to client side pages
Export-PnPClientSidePage Cmdlets applying the PnP Provisioning template and export ".xml" file into shared locaiton. Cmdlets referece can be find here
Creation of client side pages
Apply-PnPProvisioningTemplate cmdlets will create a new page within the same library from download or exported ".xml" file with provided name i.e. pagename _ duplicate
Cmdlets referece can be find here
microsoft office 365/ premium Office subscription for all your devices with exclusive monthly upgrades and new features of Word, Excel, PowerPoint, Onenote, Outlook, Publisher, Access, Supports 1 User / 5 PCs/Macs, 5 Tablets, 5 Phones Devices. Collaborate on documents with others online.
ReplyDelete
ReplyDeleteNice Blog, Best Best microsoft office deals for Mac Home and Business edition is a powerful suite which fulfils the productivity applications, written for Mac OS X.
ReplyDeleteNice Blog, best microsoft office deals for Mac Home and Business edition is a powerful suite which fulfils the productivity applications, written for Mac OS X.
microsoft office 2013 professional plus (1PC), Life Time License, Full Retail Version (1PC Take this home an improved and updated professional edition of Microsoft Office Professional Plus 2013,that works smartly and outshine among your competitors.
ReplyDeleteVery well written from Mobile and web development company in Virginia USA
ReplyDelete
ReplyDeletet20 world cup 2021 live match
icc t20 world cup 2021 live streaming
t20 world cup 2021 live tv channel
t20 world cup live streaming free
icc t20 world cup 2020 live telecast channel
t20 world cup 2021 broadcasting channel india