Sitefinity CMS enables you to automatically update the references you make from your content item to other content - media or pages - thus avoiding the need to update links manually every time referenced content is modified. As a result, there are no outdated content references and broken links.
For example, if your content item links to an image, Sitefinity CMS automatically resolves every reference to this image even after modifications such as changes in title, address, or even replacement with another image are done.
To correctly retrieve and persist content from and to the database, Sitefinity CMS includes an sfref attribute to the HTML tag of the referenced content. The sfref attribute holds important information - the Guid of content item you are referencing to and, depending on the type of content item, the following:
When you create a content item that links to other content or pages, this content item is persisted to the database. As a result, Sitefinity CMS injects the value of the sfref attribute as a value of the src attribute of the HTML tag of the content that you saved to the database. Upon retrieval from the database, Sitefinity CMS resolves this content item using a link parser. The DynamicLinkParser class in Sitefinity CMS is a Helper class for resolving and unresolving dynamic links in HTML formatted text. Depending on where you view the item from, the sfref attribute is resolved differently:
Resolve dynamic links programmatically
If you choose to implement your own logic for displaying HTML content of content items, you must resolve all links to other content - media or pages. To do so refer to the following example:
In the code above, you get an instance of the DynamicLinksParser class and call the Apply method. As a result all dynamic links in the specified HTML text are resolve to point to their actual location. When creating the DynamicLinksParser class instance, you can pass constructor parameters to remove the sfref attribute from the HTML and resolve URL's with their absolute path.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important