SFREF Attributes in Content

Posted by Community Admin on 04-Aug-2018 01:09

SFREF Attributes in Content

All Replies

Posted by Community Admin on 02-Sep-2011 00:00

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

Posted by Community Admin on 07-Sep-2011 00:00

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 >>

Posted by Community Admin on 07-Sep-2011 00:00

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

Posted by Community Admin on 13-Sep-2011 00:00

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

This thread is closed