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

Forums / Developing with Sitefinity / SFREF Attributes in Content

SFREF Attributes in Content

4 posts, 0 answered
  1. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    02 Sep 2011
    Link to this post
    Okay... see the code below:

    protected void Page_Load(object sender, EventArgs e)
    {
        //Literal Cycle = new Literal();
        ListsManager manager = ListsManager.GetManager();
        var items = manager.GetListItems()
                            .Where(i => i.Parent.Title == "Homepage Banners")
                            .Where(l => l.Status == ContentLifecycleStatus.Live);
        var totalContent = "";
     
        foreach(Telerik.Sitefinity.Lists.Model.ListItem item in items)
        {
            totalContent += item.Content.ToString();
        }
        Cycle.Text = totalContent;
    }

    item.Content returns the content from that list item with sfref attributes within it (on images). If I use the FluentAPI to get content from a list item, this should be all resolved... Is there a temporary fix for this bug?

    Thanks
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Sep 2011
    Link to this post
    Hello Conrad Ehinger,

    This is not a bug. The sfref attribute is used to tell Sitefinity that this is a dynamic link that has to be resolved. This has been the case with 3.x also. If you retrieve the content directly you will always see sfref attribute. In order to resolve the dynamic links within the content:
    ListsManager lManager = ListsManager.GetManager();
    var listItem = lManager.GetListItems().Where(lI => lI.Title == "List Item 1" && lI.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).FirstOrDefault();
    //clear SFREF attribute
    string unresolved = Telerik.Sitefinity.Web.Utilities.LinkParser.UnresolveLinks(listItem.Content);
    //resolve dynamic links to the acual content
    string resolved = Telerik.Sitefinity.Web.Utilities.LinkParser.ResolveLinks(unresolved, Telerik.Sitefinity.Modules.GenericContent.DynamicLinksParser.GetContentUrl, null, false);


    Greetings,
    Radoslav Georgiev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    07 Sep 2011
    Link to this post
    Radoslav,

    Thank you for posting that method. I'll give it a shot.

    I still feel like it is an oversight/bug. I understand the purpose of the sfref attribute. But in 3.7, it was automatically parsed out of the Content property when using the API. Something like that doesn't hold purpose in the HTML, unless it is being used by JavaScript after page load.

    Thanks,

    Chris
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Sep 2011
    Link to this post
    Hello Conrad Ehinger,

    The sfref tag is not automatically cleared in Sitefinity 3.x. It is cleared by the content view cotrols (Generic Content list, News View, Events View, etc.), when the item is rendered on the page.

    Greetings,
    Radoslav Georgiev
    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 posts, 0 answered