More in this section

Forums / Developing with Sitefinity / How can I implement a post preview word limit?

How can I implement a post preview word limit?

7 posts, 1 answered
  1. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    02 Jul 2009
    Link to this post
    Hi, where can I find code examples of how to limit a block of content to a specified number of words then have a link to the full content? I am having a brain lapse and do not know what this would be called :P

    Thanks!
    anders
  2. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    02 Jul 2009
    Link to this post
    Maybe it is called "teaser"?

    Regards,
    anders
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Jul 2009
    Link to this post
    Hi andersleet,

    Which content view based control you are referring to?

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    02 Jul 2009
    Link to this post
    It is a custom RSS control that I wrote to accomodate my specific (bass-ackwards) rss feed. It is not too much different than the standard one, just some extra properties and such so it will function the way I need it to.

    I wrote a function that I think will work, I just need to figure out how to implement it since the data this control displays is databound in the code-behind:

     protected string CreateTeaser(string Post) 
        { 
            int wordLimit = 50; 
            System.Text.StringBuilder oSB = new System.Text.StringBuilder(); 
     
            string[] splitBy = new string[] { " " }; 
     
            string[] splitPost = Post.Split(splitBy, System.StringSplitOptions.RemoveEmptyEntries); 
     
            for (int i = 0; i <= wordLimit - 1; i++) 
            { 
                oSB.Append(string.Format("{0}{1}", splitPost[i], (i < wordLimit - 1) ? " " : "")); 
            } 
     
            oSB.Append(" ..."); 
     
            return oSB.ToString(); 
        } 

    This is how it is displayed currently:

    <div class="entry"
        <p> 
            <asp:literal ID="sb_description" Text='<%# DataBinder.Eval (Container.DataItem, "description") %>' EnableViewState="false" runat="server" /></p
    </div> 

    I am open to any recommendations for this 'problem' :D

    Cheers,
    anders
  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Jul 2009
    Link to this post
    Hi andersleet,

    I am not sure if you have checked the RSS summary settings for each syndication channel. Please check the attached screenshot. This should do exactly what you need.

    Hopefully I am not misunderstanding something.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  6. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    07 Jul 2009
    Link to this post
    Nope, you got it right on. Looks like I did overlook that.

    Thanks!
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Jul 2009
    Link to this post
    Hello andersleet,

    I am glad this will fit your needs.
    Let us know if you have any other questions.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
7 posts, 1 answered