What is so special about PublishingPageContent field?
-
17-01-2021 - |
题
I work with SP2013 on-premises publishing site. There is a standard Content Type named 'Article Page', it includes field PublishingPageContent, which type is HTML.
When I create a page inside Page library and insert iframe code inside PublishingPageContent field, iframe code shows video from the same SP server's assets library, all displayed well.
For some purpose I added custom HTML field to the content type. But the problem is when I add the same iframe code to this custom field it got deleted on page save. So what is so special about PublishingPageContent field?
I tried to analyze differences between PublishingPageContent and custom HTML field using PowerShell. Maybe the only difference worth to be mentioned is RichTextMode property: in case of PublishingPageContent it is "FullHtml", in case of custom HTML it is "ThemeHtml". I tried to set RichTextMode to "FullHtml" for custom HTML field but had no luck.
Can somebody help me to understand is there is a way to make custom HTML field to behave the same way as PublishingPageContent? Or at least make it not delete iframe script? =)
Thank you!
Update: PowerShell script to update site's column
$sourceWeb = Get-SPWeb "https://shp-dev"
$listPages = $sourceWeb.Lists["Pages"] # Use list's display name
$customFieldName = "CustomHTML"; # your custom field inner name
$listField = $listPages.Fields | Where { $_.StaticName -eq $customFieldName }
write-host $listField[0].RichTextMode;
# uncomment next two lines to update field
# $listField[0].RichTextMode = "FullHtml";
# $listField[0].Update();
解决方案
You may want to retest with the RichTextMode
set to FullHtml
. Indeed, here's what we can see in the code of RichHtmlField.Validate
(as seen after reflecting with ILSpy):
bool allowIframes = htmlField.RichText && htmlField.RichTextMode == SPRichTextMode.FullHtml;