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.
Back To Top
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.