More in this section

Forums / Developing with Sitefinity / How to output a Richtext field in Feather list view

How to output a Richtext field in Feather list view

3 posts, 3 answered
  1. Ethan
    Ethan avatar
    0 posts
    Registered:
    07 Jan 2015
    22 Mar
    Link to this post

    Currently I ran into a strange bug, images in rich text field are broken in feather list(master) view.

    I have a custom module and a simple content type that contains a short text field "Title" and a rich text field "Content". And I created a custom list view that shows both Title and Content. Here is the code:

    @model Telerik.Sitefinity.Frontend.DynamicContent.Mvc.Models.DynamicContentListViewModel
    @using Telerik.Sitefinity.Frontend.Mvc.Helpers;
    @foreach (var item in Model.Items)
    {
        <div class="@Model.CssClass">
            <h2 class="title" >@item.Fields.Title</h2>
            <div class="content">
                 @Html.Raw(item.Fields.Content)
            </div>
        </div>
    }

     

    When I opened the page in chrome, the images I put in rich text are all broken, this is what I saw in the developer tool:

    <img src="[images|OpenAccessDataProvider|tmb:thumb36]12341234-1234-1234-1234-1234123412341234" data-displaymode="Thumbnail" alt="Test Image" title="test_image">

     

    It seems the image in rich text was not "translated" at all. Is there anything special I need to do if I want to output rich text in the list view?

    Answered
  2. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    23 Mar in reply to Ethan
    Link to this post

    Hi Ethan, you can resolve links like that:

    @using Telerik.Sitefinity.Web.Utilities;
    @using Telerik.Sitefinity.Modules.GenericContent;
    ...............
    @Html.Raw(LinkParser.ResolveLinks(item.Fields.Title, DynamicLinksParser.GetContentUrl, null, false))
    ...............

     

    Answered
  3. Ethan
    Ethan avatar
    0 posts
    Registered:
    07 Jan 2015
    23 Mar
    Link to this post

    Thanks Vicor, this helps a lot. Your code doesn't work instantly though because item.Fields.Content is dynamic. I got it to work by making a small modification:

    @using Telerik.Sitefinity.Frontend.Mvc.Helpers;
    @using Telerik.Sitefinity.Web.Utilities;
    @using Telerik.Sitefinity.Modules.GenericContent;
    @using Telerik.Sitefinity.Model;
     
    @Html.Raw(LinkParser.ResolveLinks(item.Fields.Content as Lstring, DynamicLinksParser.GetContentUrl, null, false))

     

    Thank you very much!

    Answered
3 posts, 3 answered