简体   繁体   中英

SharePoint Office365 Powershell Webpart AllItems.aspx

Using powershell, add webpart (image) to the list view page, eg AllItems.aspx.

This code is ok when I adding webpart to sitepage but what/how can do the same things in list

$mySite = Get-PnPClientSidePage -Identity "TestWP.aspx"
$jsonProp = '{
        "imageSourceType":0,
        "imageSource":"https://MMMMMM.sharepoint.com/sites/pwa/SiteAssets/img01.jpg",
        "captionText":" ",
        "altText":" ",
        "linkUrl":"",
        "overlayText":"",
        "fileName":"",
        "siteId":"",
        "webId":"",
        "listId":"",
        "uniqueId":"",
        "imgWidth":"100%",
        "imgHeight":"100%"
        }'
Add-PnPClientSideWebPart -Page $mySite -Section 1 -Column 1 -Order 1 -DefaultWebPartType Image -WebPartProperties $jsonProp

Eg in the AllItems.aspx view -> edit page -> Insert -> Image or Add a Web Part.

example in the link.

img01 img02

coffee, a little break and I got it

first manually adding a web part to the test page then download webpart in xml format

# get xml
$imgWebPart = Get-PnPWebPartXml -ServerRelativePageUrl "/sites/pwa/Lists/TestList03/AllItems.aspx" -Identity "Image Viewer"

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/pwa/Lists/TestList03/aa.aspx" -Xml $imgWebPart -ZoneId Main -ZoneIndex 0

sorry for the confusion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM