srefs in my links??

Posted by Community Admin on 03-Aug-2018 00:24

srefs in my links??

All Replies

Posted by Community Admin on 12-Nov-2015 00:00

I notice a lot of sref= in my html code when I create links in Sitefinity.  I know it probably does matter, but it's making the code longer and harder to read.

What is the sref and can I make SF not put it in there?    

Posted by Community Admin on 25-Nov-2015 00:00

Hello Tom,

To correctly retrieve and persist content from and to the database, Sitefinity includes an sfref attribute to the HTML tag of the referenced content. But at the Frontend, the sfref attribute is omitted, so that it does not inflate the HTML with unnecessary information.

To get more information on sfref attribute please read our documentation on "Resolve dynamic links" at http://docs.sitefinity.com/for-developers-resolve-dynamic-links.

Regards,
Arnob Makhlaqur
Telerik

 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 03-Dec-2015 00:00

Hi - Thanks for this info, as it was something I was wondering about myself.

As someone can go into HTML mode in a content block and strip out SREFs, what is the impact if someone does this?

Thanks...

mp/m

Posted by Community Admin on 08-Dec-2015 00:00

Hello Tom,

sfref is an attribute that we use to resolve dynamic links. Its value is [Provider]Guid - this shows the data provider and the item ID. When the content is saved or edited we call LinkParser.ResoveLinks and pass the entire HTML of the content item. We check for this attribute and its value. Then we set the proper href if the item is found.

To perform a check to see what might be the outcome if we remove the sfref, insert two images into the content block and then in HTML mode strip out the sfref from one image and keep the sfref for the other image and save, re-open the editor and go to HTML editor and see the difference of the two image tags, the image tag in which the sfref was removed, now has the full path / absolute path of the image location in the src value and the other image tag is having the relative path of the image in the src value. Now if we move those images to another library and go back to the page and open the content editor and open the html editor and see the image which has the sfref is automatically changed the src value to the new location of relative path but the other one still has the old full path but still the image might be visible with the wrong path as the browser may be cached that one, but will be a problem after the project deployed to another location.

So, If the sfref attribute is stripped out then the item url will not be resolved properly and when we rename/relocate the content item( image, document etc) this will break the link.

Please read the blog of Stanislav Velikov (though this blog is related to the old version) which may help to get more idea on this issue here: http://www.sitefinity.com/blogs/stanislav-velikovs-blog/2013/02/15/dynamically-resolving-sitefinity-links-when-using-htmlfield.

And also please read the following forum to get more ideas on this issue: http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity/change-in-sfref-value-causes-to-image-to-fail


Regards,
Arnob Makhlaqur
Telerik

 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed