Skip to content

Commit b6a0d60

Browse files
committed
doc updates
1 parent bbc14b7 commit b6a0d60

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

docs/transform/modernize-userinterface-site-pages-model-publishing.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Understanding and configuring the publishing page transformation model
33
description: Provides detailed guidance on how to configure and use the publishing page transformation model
4-
ms.date: 09/04/2019
4+
ms.date: 09/11/2019
55
ms.prod: sharepoint
66
localization_priority: Normal
77
---
@@ -382,6 +382,57 @@ Sometimes a page layout contains text snippets, which since they're not content
382382
> [!Note]
383383
> The HTML provided in the StaticString function must be XML encoded and must be formatted like the source page HTML as this HTML will still be converted to HTML which is compliant with the modern text editor
384384
385+
### I want to add an extra web part on the created page
386+
387+
When you transform you classic publishing page to a modern page you sometimes want to add an **additional** modern web part on the created page, without that there's a classic version of that web part on the classic publishing page. This can be done by adjusting your webpartmapping.xml and page layout mapping files as shown below.
388+
389+
First define your custom web part in your **webpartmapping.xml** file by **adding** it the `WebParts` element in the file like shown in this [standard SPFX Hello World web part](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part):
390+
391+
```XML
392+
<WebParts>
393+
...
394+
<!-- Custom Hello world web part-->
395+
<WebPart Type="SharePointPnP.Demo.HelloWorld" CrossSiteTransformationSupported="true">
396+
<Properties>
397+
<Property Name="HelloWorld" Type="string" />
398+
</Properties>
399+
<Mappings>
400+
<Mapping Default="true" Name="default">
401+
<ClientSideWebPart Type="Custom" ControlId="157b22d0-8006-4ec7-bf4b-ed62383fea76" Order="10" JsonControlData="&#123;&quot;serverProcessedContent&quot;:&#123;&quot;htmlStrings&quot;:&#123;&#125;,&quot;searchablePlainTexts&quot;:&#123;&#125;,&quot;imageSources&quot;:&#123;&#125;,&quot;links&quot;:&#123;&#125;&#125;,&quot;dataVersion&quot;:&quot;1.0&quot;,&quot;properties&quot;:&#123;&quot;description&quot;:&quot;{HelloWorld}&quot;,&quot;test&quot;:&quot;Multi-line text field&quot;,&quot;test1&quot;:true,&quot;test2&quot;:&quot;2&quot;,&quot;test3&quot;:true&#125;&#125;"/>
402+
</Mapping>
403+
</Mappings>
404+
</WebPart>
405+
...
406+
</WebParts>
407+
```
408+
409+
If you're not how to correctly define your custom web part in above **ClientSideWebPart** element then follow these steps:
410+
411+
- Navigate to the SharePoint Framework Workbench in your site (e.g. https://contoso.sharepoint.com/sites/myportalsite/_layouts/workbench.aspx)
412+
- Add your custom web part to the workbench and configure it when needed
413+
- Click on the "Web part data" button in the toolbar and then on the "Modern Pages" button
414+
- Copy the **WebPartData** json structure and use it to complete next steps:
415+
- The **ControlId** guid value is the value of the **id** json property
416+
- Delete the following json properties from the copied snippet: id, instanceIf, title and description. At this point you have the following left: `{"serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}},"dataVersion":"1.0","properties":{"description":"HelloWorld from Bert","test":"Multi-line text field","test1":true,"test2":"2","test3":true}}`
417+
- XML encode this string, this will give you this: `&#123;&quot;serverProcessedContent&quot;:&#123;&quot;htmlStrings&quot;:&#123;&#125;,&quot;searchablePlainTexts&quot;:&#123;&#125;,&quot;imageSources&quot;:&#123;&#125;,&quot;links&quot;:&#123;&#125;&#125;,&quot;dataVersion&quot;:&quot;1.0&quot;,&quot;properties&quot;:&#123;&quot;description&quot;:&quot;HelloWorld from Bert&quot;,&quot;test&quot;:&quot;Multi-line text field&quot;,&quot;test1&quot;:true,&quot;test2&quot;:&quot;2&quot;,&quot;test3&quot;:true&#125;&#125;`
418+
- If needed insert web part parameters in this string (e.g. {HelloWorld} in above sample): `&#123;&quot;serverProcessedContent&quot;:&#123;&quot;htmlStrings&quot;:&#123;&#125;,&quot;searchablePlainTexts&quot;:&#123;&#125;,&quot;imageSources&quot;:&#123;&#125;,&quot;links&quot;:&#123;&#125;&#125;,&quot;dataVersion&quot;:&quot;1.0&quot;,&quot;properties&quot;:&#123;&quot;description&quot;:&quot;{HelloWorld}&quot;,&quot;test&quot;:&quot;Multi-line text field&quot;,&quot;test1&quot;:true,&quot;test2&quot;:&quot;2&quot;,&quot;test3&quot;:true&#125;&#125;`
419+
- Paste the resulting string in the **JsonControlData** property
420+
421+
Once that's in place you need to update your page layout mapping by adding a field in the **WebParts** section that will be transformed to this custom web part:
422+
423+
```XML
424+
<WebParts>
425+
...
426+
<!-- Add an extra web part on the page -->
427+
<Field Name="ID" TargetWebPart="SharePointPnP.Demo.HelloWorld" Row="4" Column="1" Order="1">
428+
<Property Name="HelloWorld" Type="string" Functions="StaticString('PnP Rocks!')"/>
429+
</Field>
430+
...
431+
</WebParts>
432+
```
433+
434+
Ensure that specify the custom **webpartmapping.xml** file as part of your transformation (`-WebPartMappingFile` PowerShell cmdlet parameter, `PublishingPageTransformator` constructor when using .Net).
435+
385436
### Can I control the page preview image (as of the May 2019 release)
386437

387438
When a page has a page header image that image will also be used as a page preview image. If you however want to control the page preview image then you can populate the `BannerImageUrl` field using either the `ToPreviewImageUrl` function or by specifying a hard coded value as shown in below samples.

0 commit comments

Comments
 (0)