By default, all built-in and dynamic Sitefinity CMS widgets, which can display content items, register the items’ locations and generate the items’ links using the ContentLocationService. When you place such widget on a page and publish the page, each widget sends data to Sitefinity CMS. The data contains the items that the widget displays, their type, and the page they appear on.
When you are using your own custom widgets to display Sitefinity CMS content items, you must manually register for the ContentLocationService. This way, Sitefinity CMS will know the locations of the content items displayed with you custom widget.
When you publish a page, Sitefinity CMS check for all widgets on the page that implement the IContentLocatableView interface, and for each of them it gets the location information.
If you want your custom widget to have a canonical URL and to provide a location for items, you must implement the IContentLocatableView interface.
This interface defines the common information that must be provided by each widget that is able to show content items. It is used for the preview of content items and for issuing a canonical link element for SEO.
You implement the interface, by implementing method IEnumerable<IContentLocationInfo> GetLocations() and property DisableCanonicalUrlMetaTag
The GetLocations() method is called by Sitefinity CMS upon page publish and returns the specific location information about the item type and provider that is used to display the items, it also tells Sitefinity CMS what type of content is displayed on the page. This information is described by the IContentLocationInfo interface.
This interface provides the information for manipulating content location. It is used by the content widgets that can show content items. The content type and the provider name properties are required parameters, in order to specify uniquely the source of the items that will be displayed by the widgets. The Priority, RedirectPageId, and Filters properties are not obligatory and can be used to fine tune the content location information.
Sitefinity CMS provides a straight forward implementation of this interface – the ContentLocationInfo class. You can use it wherever the interface is required.
This property is used by Sitefinity CMS to determine whether the widget should resolve or not the canonical (default) URL of the item when building the links.
You can disable the canonical URL functionality for this widget by using the DisableCanonicalUrlMetaTag. If you disable it – the widget will still be available as a preview location.
You use this interface to register a location for a filtered collection of items.
If your widget displays only a filtered collection of items form a specified type, for example filtered by Tag, you must specify this, otherwise Sitefinity CMS consider this location valid for all items of the registered type, and uses this location to resolve URLs of all items, not only the filtered ones.
To achieve this you need to apply an IContentLocationFilter to the location you return in your GetLocations() implementation.
The IContentLocationFilter represents the filter applied to the content location. You can specify a Name and Value properties for the filter. The Value represents a FilterExpression which is parsed by Sitefinity CMS when working with this location. It determine which items are displayed on this location.
Back To Top