Sitefinity MVC Widget Best Practices
sitefinity | NET, CMS, Sitefinity | 2020-08-20
sitefinity | NET, CMS, Sitefinity | 2020-08-20
In this sample, I have implemented
It has the main functionality for constructing all the out-of-the-box SEO properties, supporting listing and detail pages. When this class is implemented, you will be able to call the InitializeMetadataDetailsViewBag method, pass in it the item that is currently being displayed and based on the item and the SEO configurations of the site, Sitefinity will automatically create OG and normal SEO properties. Sitefinity GitHub
To verify IContentLocatableView, we have to
Then go to the content type page, either
1/
2/
The implementation of this interface will provide proper cache invalidation for the respective content type, in the custom widget.
When developing your own user or custom widget, to invalidate the cache, you need to implement the appropriate cache dependencies in order.
This way, when you create or modify a content item, the widget cache is invalidated in order to reflect the latest changes in the content.
For example, if you place an MVC widget displaying news items on the page. When you change the news content, the cache of the page with the widget is invalidated and the controller action is not called.
With this method, the Controller should mark the Url Parameters as resolved, so the system knows that this Url and parameters will be handled and this is not a 404 Not Found.
To verify HandleUnknownAction, we have to
Eg. Install custom widget at About page, have
When editor publish a page with the custom widget installed. IContentLocatble’s GetLocations will notify Sitefinity to register the URL where the content type will be display to public.
Implementing by IHasCacheDependency / SubscribeCacheDependency() at custom widget’s (controller) code. It will invalidate cache when a new content type is created.
Create a HandleUnknownAction to route 404 to a meaningful page.
The recommended solution is extending the view of content type generated (auto generated when a new custom module is created). By extending the view, all Sitefinity best practices are inherited by default. eg. (Refer to bootstrap / boockstrap4 folder) /ImageGallery /List.MyGallery.cshtml /Detail.MyGallery.cshtml