Creating a Duplicate Page in different Site Collection

%3CLINGO-SUB%20id%3D%22lingo-sub-220309%22%20slang%3D%22en-US%22%3ECreating%20a%20Duplicate%20Page%20in%20different%20Site%20Collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-220309%22%20slang%3D%22en-US%22%3E%3CP%3EHaving%20watched%20the%20PnP%20video%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Foffice%2Fblogs%2Fprogramatically-creating-and-updating-modern-pages-in-sharepoint-online%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EProgrammatically%20creating%20and%20updating%20modern%20pages%20in%20SharePoint%20Online%3C%2FSPAN%3E%3C%2FA%3Eby%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5670%22%20target%3D%22_blank%22%3E%40Bert%20Jansen%3C%2FA%3Eand%26nbsp%3B%40VesaJuvonen%2C%20I%20saw%20that%20it%20was%20possible%20to%20create%20a%20new%20page%20and%20to%20set%20its%20contents%20using%20the%20CanvasContent1%20property%20of%20the%20new%20page.%20I%20would%20like%20to%20create%20a%20duplicate%20of%20a%20page%20in%20a%20second%20site%20pages%20library%20in%20a%20different%20site%20collection%2C%20so%20that%20it%20has%20all%20the%20same%20sections%2C%20web%20parts%20and%20content%20of%20the%20original.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20do%20this%20with%20PnP%20PowerShell%2C%26nbsp%3Bbut%20I%20notice%20in%20the%20documentation%20for%20the%20Set-PnPClientSidePage%20cmdlet%20that%20this%20is%20not%20one%20of%20the%20properties%20that%20is%20available%20to%20set%20via%20a%20parameter%20to%20the%20cmdlet.%26nbsp%3B%20How%20can%20I%20access%20this%20property%20in%20both%20the%20source%20and%20target%20pages%3F%20I%20would%20like%20to%20do%20something%20like%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPage2.properties%5B%22%3CSPAN%3ECanvasContent1%3C%2FSPAN%3E%22%5D%20%3D%20Page1.properties%5B%22CanvasContent1%22%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20way%20this%20is%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-225877%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20Duplicate%20Page%20in%20different%20Site%20Collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225877%22%20slang%3D%22en-US%22%3E%3CP%3E%26lt%3B%3CBUMP%3E%26gt%3B%3C%2FBUMP%3E%3C%2FP%3E%3CP%3ESo%20what%20is%20the%20current%20story%20on%20Modern%20News%20pages%20that%20need%20to%20be%20in%20multiple%20languages%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20my%20customer%20creates%20a%20news%20page%20in%20English%2C%20I%20need%20that%20page%20to%20be%20copied%20with%20all%20of%20its%20contents%20to%202%20other%20sites%20(each%20one%20set%20up%20with%20a%20different%20default%20language)%2C%20where%20authors%20can%20change%2Ftranslate%20the%20title%20and%20text%20and%20then%20publish.%20They%20should%20not%20have%20to%20%22rebuild%20the%20page.%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20this%20be%20accomplished%20in%20the%20new%20%22modern%22%20architecture%3F%26nbsp%3B%20Flow%20will%20not%20let%20me%20just%20%22copy%20the%20page%22%20to%20the%20Site%20Pages%20library%20of%20the%20other%20language%20sites.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-222267%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20Duplicate%20Page%20in%20different%20Site%20Collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-222267%22%20slang%3D%22en-US%22%3E%3CP%3E%26gt%3B%26gt%3B%3CSPAN%3EYou%20basically%20have%20to%20hand%20craft%20out%20and%20script%20each%20element%20of%20the%20page%3C%2FSPAN%3E%26lt%3B%26lt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOkay%2C%20but%20why%20is%20that%20the%20case%3F%26nbsp%3B%20The%20video%20I%20referenced%20goes%20out%20of%20its%20way%20to%20say%20that%20%22this%20is%20the%20content%20of%20the%20page%22.%20It's%20shown%20to%20be%20a%20string.%20Not%20sure%20why%20moving%20the%20contents%20of%20one%20property%20to%20another%20is%20an%20issue%2C%20especially%20if%20they%20are%20the%20same%20type%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26gt%3B%26gt%3B%3CSPAN%3Eif%20you're%20only%20doing%20this%20for%20one%20site%20collection%20your%20probably%20better%20off%20just%20manually%20building%20out%20the%20page%3C%2FSPAN%3E%26lt%3B%26lt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESorry%20but%20this%20is%20EXACTLY%20the%20scenario%20we%20are%20trying%20to%20*avoid.*%20It%20needs%20to%20be%20done%20in%20TWO%20site%20collections%20where%20the%20pages%20will%20be%20saved%20as%20drafts%26nbsp%3Band%20then%20manually%20translated%26nbsp%3Binto%20different%20languages%20on%20site%20in%20those%20countries.%20They%20should%20only%20have%20to%20change%20the%20text%20to%20the%20correct%20language%20and%20then%20hit%20Publish%2C%20not%20have%20to%20completely%20rebuild%20the%20page%20each%20time%20there's%20a%20relevant%20piece%20of%20news%20in%20that%20country.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%2C%20the%20localization%20story%20for%20news%20in%20%22modern%22%20is%20very%20incomplete%20and%20I%20am%20desperately%20trying%20to%20come%20up%20with%20some%20kind%20of%20work%20around%20that%20will%20convince%20a%20paying%20customer%20that%20going%20the%20Microsoft-recommended%20route%20is%20worth%20doing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26gt%3B%26gt%3B%3CSPAN%3EThe%20site%20scripting%20is%20mainly%20for%20site%20templates%20and%20deploying%20custom%20solutions%20and%20pages%26nbsp%3B%3C%2FSPAN%3E%26lt%3B%26lt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESure%2C%20but%20that's%20not%20really%20relevant%20--%20people%20have%20been%20re-purposing%20things%20forever.%26nbsp%3B%20Cars%20are%20for%20getting%20people%20from%20one%20place%20to%20another%2C%26nbsp%3B%20but%20some%20people%20race%20them%2C%20some%20people%20live%20in%20them%20and%20some%20people%20use%20them%20to%20create%20works%20of%20art.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20failing%20the%20simple%20property%20update%2C%20is%20there%20at%20least%20some%20way%20to%20open%20up%20the%20existing%20page%20and%20cycle%20through%20it's%20structure%20so%20it%20can%20be%20duplicated%20in%20an%20automated%20loop%2C%20without%20having%20to%20be%20structured%20by%20hand%3F%20Like%20Psuedo%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eobj%20%3D%20pageonecontent%3C%2FP%3E%3CP%3Eobj2%20%3D%20newpage()%3C%2FP%3E%3CP%3Eforeach%20%24element%20in%20obj%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bobj2.add-element(%24element)%3C%2FP%3E%3CP%3Enext%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-220339%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20a%20Duplicate%20Page%20in%20different%20Site%20Collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-220339%22%20slang%3D%22en-US%22%3EIt's%20not%20quite%20that%20easy%20to%20do%20%3AP.%20You%20basically%20have%20to%20hand%20craft%20out%20and%20script%20each%20element%20of%20the%20page%20from%20the%20list%20content%20to%20everything%20else.%20So%20if%20you're%20only%20doing%20this%20for%20one%20site%20collection%20your%20probably%20better%20off%20just%20manually%20building%20out%20the%20page%20to%20match.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20site%20scripting%20is%20mainly%20for%20site%20templates%20and%20deploying%20custom%20solutions%20and%20pages%20etc.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Having watched the PnP video Programmatically creating and updating modern pages in SharePoint Online by @Bert Jansen and @VesaJuvonen, I saw that it was possible to create a new page and to set its contents using the CanvasContent1 property of the new page. I would like to create a duplicate of a page in a second site pages library in a different site collection, so that it has all the same sections, web parts and content of the original.

 

I would like to do this with PnP PowerShell, but I notice in the documentation for the Set-PnPClientSidePage cmdlet that this is not one of the properties that is available to set via a parameter to the cmdlet.  How can I access this property in both the source and target pages? I would like to do something like:

 

Page2.properties["CanvasContent1"] = Page1.properties["CanvasContent1"]

 

Is there any way this is possible?

 

Thanks

3 Replies
Highlighted
It's not quite that easy to do :P. You basically have to hand craft out and script each element of the page from the list content to everything else. So if you're only doing this for one site collection your probably better off just manually building out the page to match.

The site scripting is mainly for site templates and deploying custom solutions and pages etc.

Highlighted

>>You basically have to hand craft out and script each element of the page<<

 

Okay, but why is that the case?  The video I referenced goes out of its way to say that "this is the content of the page". It's shown to be a string. Not sure why moving the contents of one property to another is an issue, especially if they are the same type .

 

>>if you're only doing this for one site collection your probably better off just manually building out the page<<

 

Sorry but this is EXACTLY the scenario we are trying to *avoid.* It needs to be done in TWO site collections where the pages will be saved as drafts and then manually translated into different languages on site in those countries. They should only have to change the text to the correct language and then hit Publish, not have to completely rebuild the page each time there's a relevant piece of news in that country.

 

Basically, the localization story for news in "modern" is very incomplete and I am desperately trying to come up with some kind of work around that will convince a paying customer that going the Microsoft-recommended route is worth doing.

 

>>The site scripting is mainly for site templates and deploying custom solutions and pages <<

 

Sure, but that's not really relevant -- people have been re-purposing things forever.  Cars are for getting people from one place to another,  but some people race them, some people live in them and some people use them to create works of art. 

 

So failing the simple property update, is there at least some way to open up the existing page and cycle through it's structure so it can be duplicated in an automated loop, without having to be structured by hand? Like Psuedo code:

 

obj = pageonecontent

obj2 = newpage()

foreach $element in obj

   obj2.add-element($element)

next

 

Thanks

Highlighted

<<BUMP>>

So what is the current story on Modern News pages that need to be in multiple languages?

 

When my customer creates a news page in English, I need that page to be copied with all of its contents to 2 other sites (each one set up with a different default language), where authors can change/translate the title and text and then publish. They should not have to "rebuild the page."

 

How can this be accomplished in the new "modern" architecture?  Flow will not let me just "copy the page" to the Site Pages library of the other language sites.

 

Thanks.