powershell icon indicating copy to clipboard operation
powershell copied to clipboard

Export-PnpPage keeps the default header type instead of the correct type.

Open Dangerous-Mind opened this issue 3 years ago • 4 comments

Expected behavior

Export-PnPPage templates/Template.aspx -Out Template.xml

Returns: <pnp:Header Type="Default" LayoutType="NoImage" TextAlignment="Center" ShowTopicHeader="false" ShowPublishDate="false" TopicHeader="" AlternativeText="" Authors="[]" AuthorByLine="[]" AuthorByLineId="-1" />

Since the header Type is Default, SharePoint will ignore parameters like LayoutType and TextAlignment . To workaround we need to change the type to Custom

Steps to reproduce behavior

  1. Create a page and make any change to the header ( align text center or remove the image)
  2. Export the template Export-PnPPage templates/Template.aspx -Out Template.xml
  3. Provision the template.

What is the version of the Cmdlet module you are running?

PnP.Powershell 1.9.0

Which operating system/environment are you running PnP PowerShell on?

  • [x] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

Dangerous-Mind avatar Jan 14 '22 15:01 Dangerous-Mind

@Dangerous-Mind - is this still an issue ? Can you please try with latest release and let us know ?

gautamdsheth avatar Jun 16 '22 11:06 gautamdsheth

@gautamdsheth, just confirmed with version 1.10.0

A page with the 'NoImage' layout is still being exported as <pnp:Header Type="Default" LayoutType="NoImage" ShowTopicHeader="false"... which actually should be <pnp:Header Type="Custom" LayoutType="NoImage" ShowTopicHeader="false" using the command Get-PnPSiteTemplate -Out ./test.xml -Handlers PageContents,Pages -IncludeAllPages

SjoerdV avatar Jun 16 '22 19:06 SjoerdV

I can confirm this issue on 1.11. We have an workaround for our page migration script, by rebuilding the template (get it via Export-PnPPage) in the following way:

[xml]$xml = $template $newAttr = $xml.CreateAttribute('ServerRelativeImageUrl') $xml.Provisioning.Templates.ProvisioningTemplate.ClientSidePages.ClientSidePage.Header.Attributes.Append($newAttr) $xml.Provisioning.Templates.ProvisioningTemplate.ClientSidePages.ClientSidePage.Header.ServerRelativeImageUrl="/sites/demo1/assets/myimage.png" $xml.Provisioning.Templates.ProvisioningTemplate.ClientSidePages.ClientSidePage.Header.Type = 'Custom' $xml.OuterXml | Out-File -FilePath './pageTemplate.xml' -Force

after this manipulation we can successfully use Invoke-PnPSiteTemplate

In our case, we have the page header with no image, but with TopicHeader (this prop is successfully exported via cmdlet)

ruslan-s avatar Aug 06 '22 19:08 ruslan-s

Hi Team, Any update on this issue ? I believe this even exists when you export-pnpsitetemplate....

Thanks, Divyansh

divya66 avatar Aug 11 '22 10:08 divya66

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Dec 24 '22 02:12 github-actions[bot]

Still no news?

Dangerous-Mind avatar Dec 24 '22 12:12 Dangerous-Mind

Can you please update to the latest 2.1.x however PS 7.2 or later is needed to benefit from all the bug fixes and improvements of that new release.

PS5 support has been dropped.

Feel free to reopen if the issue persists. Thanks.

veronicageek avatar Apr 11 '23 11:04 veronicageek

This appears to still be an issue on PNP version 2.2

themacksta avatar Aug 09 '23 04:08 themacksta