1

I want to be able to to add a summary column to my blog posts for ease of visual to another site. At first I attempted a Calculated column

=LEFT([Body], 140)

But that doesn't work, I assume because a blog's body is richtext. Does anyone know how I can create another column for the Post list on a blog that would be a shortened version of the Body column?

Thanks.

3

You are right, the body field has rich-text as a data type that is is not supported in calculated field formulas.

So , if you need to create a new field that will hold summary data from body field , try to Create simple custom workflow via SharePoint designer, and use Extract String from start of string and update list item action as the following :

  • In your list add Summary Body field that will hold the summary data 140 character,
  • Open SharePoint Designer > click on Workflow > from the above ribbon > select - List Workflow And select your Blog List.
  • From the Above Ribbon, > Action > select String from start of string`

enter image description here

  • Set the number of character that you need (140), select body field , and set it at variable.

  • Then add update list item action to update the summary body field from this variable

Workflow should look like

enter image description here

But if you need to customize Blog home page to show in summery with button read more , in this case, you can truncate HTML content via JSLink by setting var headlineLimit = 140;

(function () {

    var rCtx = {};
    rCtx.Templates = {};
    rCtx.Templates.Fields = {
        'Body': { 'View' : renderHeadline }
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(rCtx);
})();


function renderHeadline(ctx) {
    var headlineLimit = 140;
    var body = ctx.CurrentItem.Body;  
    var headline = $(body).text(); 
    if (headline.length > headlineLimit)
    {
        headline = headline.substring(0,headlineLimit) + '&nbsp;&nbsp;&nbsp;<b><a href="' + ctx.listUrlDir + '/Post.aspx?ID=' + ctx.CurrentItem.ID + '">More ...</a></b>';
    }
    return headline;
}

For JSLINK , Check the detail steps at Sharepoint Online - How to show blogs in excerpt format

  • Thanks M! This was great. The only thing I would add to anyone watching is when setting the start string make sure you tell it plain text so it removes any HTML tags when creating the variable. – Robin Huighe Sep 29 '16 at 0:05

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.