SFREF Attributes in Content
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;
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
);
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 >>
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
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