none
Sharepoint Blog/ how to set a "read more" link to limit the lines of text on the posting? RRS feed

  • Question

  • Hi folks,
    I am  looking for the switch to limit the lines of text showing on a blog post, and to have a "read more", or "more" link to the category. Can you advise me? Thank you in advance, Gary

    Monday, October 26, 2009 7:01 PM

Answers

  • Hi,

    I think you can limit the text in a post using SharePoint Designer:

    1.     Open the blog site in SPD and open the default.aspx page;

    2.     Locate the post list view, and "Convert to XSLT Data View";

    3.     Look for the body text, you will see the code like this: <xsl:value-of select="@Body"/>;

    4.     Replace the code to this <xsl:value-of select="substring(@Body,1,62+m)"/> (“m” is the count of the characters you want to display in the post). If the code like this <xsl:value-of select="substring(@Body,1,72)"/> , it will display 10 characters in the default page.

    If you want to set “read more” link, I think you should use JavaScript to set the button.

    Hope it helps.


    Xue-Mei Chang
    Wednesday, October 28, 2009 7:46 AM
    Moderator
  • Hi Gary!

    This is a great post on how to achieve this, and also how to avoid that half words are displayed etc: http://mdasblog.wordpress.com/2009/01/20/displaying-the-first-n-words-of-a-long-text-column-with-xsl/

    Good luck!
    Jenny
    Wednesday, October 28, 2009 8:08 AM

All replies

  • Hi,

    I think you can limit the text in a post using SharePoint Designer:

    1.     Open the blog site in SPD and open the default.aspx page;

    2.     Locate the post list view, and "Convert to XSLT Data View";

    3.     Look for the body text, you will see the code like this: <xsl:value-of select="@Body"/>;

    4.     Replace the code to this <xsl:value-of select="substring(@Body,1,62+m)"/> (“m” is the count of the characters you want to display in the post). If the code like this <xsl:value-of select="substring(@Body,1,72)"/> , it will display 10 characters in the default page.

    If you want to set “read more” link, I think you should use JavaScript to set the button.

    Hope it helps.


    Xue-Mei Chang
    Wednesday, October 28, 2009 7:46 AM
    Moderator
  • Hi Gary!

    This is a great post on how to achieve this, and also how to avoid that half words are displayed etc: http://mdasblog.wordpress.com/2009/01/20/displaying-the-first-n-words-of-a-long-text-column-with-xsl/

    Good luck!
    Jenny
    Wednesday, October 28, 2009 8:08 AM
  • Hi Chang,

    Can you please share the JavaScript code to add more link with 2 line as you mentioned above.

    Waiting for your quick response.

    Thank you

    Thursday, June 19, 2014 2:28 PM