6

I'm using SharePoint 2013. In our blog post we often use a lot of images and text so the current layout just doesn't work.

I'm looking for a way to display a link to a read more page.

  • 1
    I posted a similar question for sp2010. Not sure if this will get you on the right track.... sharepoint.stackexchange.com/questions/84377/… – BlueBird Jan 31 '14 at 13:52
  • It works, but, if you hit the back button on the browser, all the blog posts are expanded. Or if you click the 'read more' link then go to the home page, the blog posts are all still expanded. – user29498 Jun 9 '14 at 23:35
5

How to customize SharePoint Blogs using client-side rendering (CSR)

Since the client side rendering (CSR) is the default rendering mode in SharePoint 2013, below is demonstrated how to override Body field in such a way that the link for the post will be displayed via CSR.

And the resulting page could look like this

enter image description here

Example: how to override Blog view

A. Create rendering template, lets name it Blogs.js

(function () {

    function blogBodyRenderer(ctx) {
       var item = ctx.CurrentItem;
       return '<a href="' + ctx.listUrlDir + '/Post.aspx?ID=' + item.ID + '" class="ms-accentText">Read more...</a>';  
    }


    function registerBlogsRenderer()
    {
      var blogContext = {};
      blogContext.Templates = {};
      blogContext.Templates.Fields = {
        "Body": {
            "View": blogBodyRenderer
        }
      };

      SPClientTemplates.TemplateManager.RegisterTemplateOverrides(blogContext);
    } 
    ExecuteOrDelayUntilScriptLoaded(registerBlogsRenderer, 'clienttemplates.js');

})();

Gist

B. Upload JavaScript file into Site Assets library

C. Open Blog home page in Edit mode (Edit page). Specify for Posts web part JS Link property:

~sitecollection/SiteAssets/Blogs.js

enter image description here

  • 1
    Brilliant informed answer. Thank you Although I have yet tried this, I am sure this will work :) Thank you again. – Wessel Feb 3 '14 at 8:52
  • David, I'm glad I could help, it should work properly, tested it against SharePoint Online :) – Vadim Gremyachev Feb 3 '14 at 9:28

protected by Community Mar 16 '17 at 14:15

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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