We are using O365/Sharepoint Online 2013.
We are using a Sharepoint Online Blog as the official intranet news channel and it's all good but we are irritated about having the posts with full content showing on the blog summary/blog main page as some of our posts are quite long. How could we limit how much users can see of the posts' content on the summary page? I found one guide with a Javascript code for blog post excerpt but it doesn't fully work. Here is the code:
(function () {
// Initialize the variables for overrides objects
var overrideCtx = {};
overrideCtx.Templates = {};
/*
* Using the Fields override leaves the rest of the rendering intact, but
* allows control over one or more specific fields in the existing view
*/
overrideCtx.Templates.Fields = {
'Body': { 'View' : CustomField }
};
/*
* Register the template overrides.
*/
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
function CustomField(ctx) {
// Really basic field-level conditional formatting
var ret
ret = ctx.CurrentItem.Body;
if (ret.length > 400)
{
ret = ret.substring(0, 400) + ' <b><a href="/Blog/Lists/Posts/Post.aspx?ID=' + ctx.CurrentItem.ID + '">More ...</a></b>';
}
return ret;
}
I pasted that code into a empty file and saved it as "blogexcerpt.js" into the Site Collection root "Site assets" -folder. Then I went into the blog site with the Admin account and edited the Posts -web part and added "~sitecollection/_catalogs/masterpage/blogexcerpt.js" and applied and saved + closed the web part configuration window/box.
The posts were truncated but they only showed about one line of text and the alignment of the post boxes were a bit messed up too. There were no space between the post boxex/entries and they had "object/Object" -text under the post titles.
EDIT: I have almost no skills in writing JS and the code is from this discussion: http://social.technet.microsoft.com/Forums/sharepoint/en-US/9bb0033e-d17b-4c4f-b6c3-2df3d4eb00bf/show-blogs-in-excerpt-format
EDIT 2: I noticed the code that I found from the link above is quite old so is it possible that something in the SPO core code has changed and the code is referencing to some old core code terms or something like that?
I will be eternally grateful to aynone who can help us out with this problem! :-)