0

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.

1

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 &lt; and > as &gt;

This way the code <h2>Header</h2> becomes &lt;h2&gt;Header&lt;/h2&gt;

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.

  • Just comment that the char " has to be replaced by &#34; as well – Txemanu Sep 5 '16 at 15:06
0

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. – user5579208 Mar 10 '16 at 19:09
0

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. – Evariste Mar 10 '16 at 18:44
  • Not everyone (including me) has powershell access. – Erin L Mar 10 '16 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.