pnpframework icon indicating copy to clipboard operation
pnpframework copied to clipboard

ConvertTo-PnPPage IncludeVerticalColumns throws Index out of Range error

Open natpdeee opened this issue 4 years ago • 2 comments

When trying to do a page modernization, ConvertTo-PnPPage throws an error when we specify IncludeVerticalColumn = true in the page layout mapping file. Header and Metadata tags have been removed from the sample below.

<PageLayout Name="SomePageLayout" AssociatedContentType="" PageLayoutTemplate="AutoDetect" IncludeVerticalColumn="true" PageHeader="Custom">
      <SectionEmphasis VerticalColumnEmphasis="Soft">
      </SectionEmphasis>
      <WebParts>
        <Field Name="PublishingPageContent" TargetWebPart="SharePointPnP.Modernization.WikiTextPart" Row="1" Column="1" Order="1">
          <Property Name="Text" Type="string" />
        </Field>
      </WebParts>
      <WebPartZones>
        <WebPartZone ZoneIndex="0" ZoneId="BottomZone" Row="1" Column="1" />
      </WebPartZones>
</PageLayout>

Error Message: image

Command Run:

ConvertTo-PnPPage -RemoveEmptySectionsAndColumns:$false -Identity $page.FieldValues.FileLeafRef   -TargetWebUrl $targetUrl -CopyPageMetadata -PageLayoutMapping "$($folderLocation)\$($mappingName)"   -PublishingPage -ErrorAction Stop 

Expected Outcome: The page modernization works and adds a blank vertical column to the page.

natpdeee avatar Feb 04 '22 05:02 natpdeee

@natpdeee : can you try putting something in column 2 and see if that makes a difference? Below snippet just adds some text, so easy to use

<Field Name="ID" TargetWebPart="SharePointPnP.Modernization.WikiTextPart" Row="1" Column="2">
  <Property Name="Text" Type="string" Functions="StaticString('&lt;H1&gt;This is some extra text&lt;/H1&gt;')" />
</Field>

jansenbe avatar Mar 17 '22 08:03 jansenbe

That will fix the problem.

My Pull Request 614 fixes that problem. In the PublishingLayoutTransformer Transform method the maxColumns is 0. Setting it to 1 fixes the problem

robi26 avatar Mar 17 '22 08:03 robi26