pnp / pnp/powershell

[BUG] Set-PnPPageTextPart returns You cannot host text controls inside a one column full width section ...

Open
#4,719 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
904
Forks
407
Avg merge
9h 16m
Merged PRs (30d)
10

Description

Reporting an Issue or Missing Feature

Set-PnPPageTextPart returns error You cannot host text controls inside a one column full width section, only an image web part or hero web part are allowed after Microsoft pushed updates to Page layout options.

Expected behavior

Change text webpart text. The issue is probably related to the recent Microsoft updates to top page section, which now allows fullwidth section with webparts instead of only banner or hero.
Related to

Actual behavior

Error: Set-PnPPageTextPart : You cannot host text controls inside a one column full width section, only an image web part or hero web part are allowed
At line:32 char:17

Steps to reproduce behavior

#variables
$siteUrl = "xxx"
$oldText = "abc"
$newText = "def"

#script

Connect-PnPOnline uuu -clientID yyy
 
# Get all pages from the Site Pages library
$pages = Get-PnPListItem -List "Site Pages"
 
foreach ($pageItem in $pages) {
    # Get the file name of the page
    $pageName = $pageItem.FieldValues["FileLeafRef"]
    Write-Host "Processing page: $pageName" -ForegroundColor Yellow
 
    # Load the page
    $page = Get-PnPClientSidePage -Identity $pageName
 
    if ($page) {
        foreach ($webPart in $page.Controls) {
            if ($webPart.Type.Name -eq "PageText") {
                $textContent = $webPart.Properties["Text"]

                # Replace old text with new text
                $updatedTextContent = $textContent -replace [regex]::Escape($oldText), $newText
 
                # Update the text part
                #Set-PnPPageTextPart -Page $pageName -Text $updatedTextContent -InstanceId $webPart.InstanceId
                # $instanceIdString = $webPart.InstanceId.ToString()
                #Write-Host "Text webpart $instanceIdString.InstanceId updated successfully for page $pageName." -ForegroundColor Green
            }
        }
    } else {
        Write-Host "Page not found or could not be loaded: $pageName" -ForegroundColor Red
    }
}
What is the version of the Cmdlet module you are running?

1.12.0

Which operating system/environment are you running PnP PowerShell on?
  • [ x] Windows

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Set-PnPPageTextPart cmdlet and reproduce the failure using the PowerShell script in the issue against a page with a full-width section. Read related issue 1045 and inspect how the cmdlet handles the page's controls; done means updating the text web part succeeds in the affected full-width layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.