I have a custom content type, say "MyCompany Article Page" inheriting from standard "Article Page" content type. In my associated custom publishing layout, how do i pre-populate some HTML rich content in the "Page Content" field?
I'm looking for a way to do this in Design Manager, SharePoint 2013. I created the custom page layout using Design Manager.
3 Answers
This is possible to do from your custom page layout HTML file, but requires some jiggery-pokery to work properly.
If you navigate to the Page Content Snippet in your HTML page, you can add html by editing the following line:
<!--MS:<PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server">-->
simply edit it like so:
<!--MS:<PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server" Html="This is my HTML">-->
Note, however, that this will only accept text, if you try to add <h3>
or other bracketed code, it will break the input, as < & > are used as code delimiters in Sharepoint. To get around this, you need to write:
<
as <
and >
as >
This way the code <h2>Header</h2>
becomes <h2>Header</h2>
While this is a bit awkward and long-handed, it is the method I use to directly implement templates into a custom publishing page content snippet.
If I understand correctly your question, you simply need to set a default value for your Rich Text field. This cannot be done from the UI, but can easily be achieved by PowerShell: see for instance http://social.technet.microsoft.com/wiki/contents/articles/28386.powershell-to-set-up-default-value-for-rich-text-field-in-sharepoint-2010.aspx.
The PowerShell code would be like:
$web = Get-SPWeb <Absolute-URL-of-Root-Site>
$f = $web.Fields["<FieldInternalName"]
$f.DefaultValue = "<YOUR HTML STRING>"
$f.Update()
-
actually here is the scenario, I've 3 types of News Content Type. Event,Communication and Company News. Each Content Type inherit from Article Page. Now "Page Content" which is a Publishing HTML type, I want different dafault content with different content for Event, Communication and Company in this field. I cannot stick default content in the generic Site Column - "Page Content" as i want it to change based on the Content Type. Mar 10, 2016 at 19:09
You could write a workflow in SharePoint Designer to set the field on that content type when the document is created.
-
Please, please, please, no big/buggy/slow/heavy/UI-visible workflows for such a technical task... Workflows (technical) are for workflows (functional)... at the best.– EvaristeMar 10, 2016 at 18:44
-