Custom Blog Widget- Strip html from Blog Summary

Posted by Community Admin on 04-Aug-2018 20:51

Custom Blog Widget- Strip html from Blog Summary

All Replies

Posted by Community Admin on 26-Oct-2011 00:00

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.


Posted by Community Admin on 27-Oct-2011 00:00

Any suggestions!!!

Posted by Community Admin on 31-Oct-2011 00:00

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

Posted by Community Admin on 01-Nov-2011 00:00

Boyan,
Thank you for your response.
Regards,
San

This thread is closed