1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Blog Widget- Strip html from Blog Summary

Custom Blog Widget- Strip html from Blog Summary

4 posts, 0 answered
  1. san
    san avatar
    61 posts
    Registered:
    20 Aug 2010
    26 Oct 2011
    Link to this post
    Hello,

    We have just started working with Sitefinity 4.2. And, I am trying to create a custom widget template for the list items. I followed the post by Radoslav and I was able to limit the content for a blog item to 20 words. I would like to strip all the html tags in the summary item that I display? Can you please provide me some suggestion on how can I strip all the html from the 20 words summary that I am displaying so that images or other styling is not displayed.

    This is what I presently have to show the summary:
      
    <sitefinity:HtmlField runat="server" DisplayMode="Read" Value='<%# SummaryParser.GetSummary(Eval("Content").ToString(),new SummarySettings(SummaryMode.Words,20,false,false)) %>' />


    Also could you please direct me to some example documentation for creating custom widgets for modules? Any examples would be great to see.

    Thank you for all your time.


  2. san
    san avatar
    61 posts
    Registered:
    20 Aug 2010
    27 Oct 2011
    Link to this post
    Any suggestions!!!
  3. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    31 Oct 2011
    Link to this post
    Hi San,

    That's a tough one, currently we do not have a control that converts HTML into text. The closest to that functionality is our TextField control, however it will render the HTML tags as plain text.Alternatively you can create an external template and strip the HTML tags in your code, for example:
    public string Strip(string text)
    {
        return Regex.Replace(text, @”<(.|\n)*?>”, string.Empty);
    }
    For more information on mapping external templates to Sitefinity 4.x widgets, please check these resources:
    Customizing Sitefinity 4 Controls with the ViewMap
    Mapping External Templates for Sitefinity 4 Widgets

    Concernign your second request, I'd recommend you to install our Sitefinity SDK and take a look at the ProductsCatalog sample that we have made available, it is a complete content-based module and you can inspect how the public widgets are created (it's based on our NewsView widget).

    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. san
    san avatar
    61 posts
    Registered:
    20 Aug 2010
    01 Nov 2011
    Link to this post
    Boyan,
    Thank you for your response.
    Regards,
    San
4 posts, 0 answered