+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Preview Custom Module content with custom MVC controller widget?

Preview Custom Module content with custom MVC controller widget?

3 posts, 1 answered
  1. Eric
    Eric avatar
    5 posts
    Registered:
    14 May 2015
    27 Apr
    Link to this post

    Hope I'm asking this the right way - sorry if it's confusing.

    In Sitefinity 8.2.59 we used the Module Builder to create a new custom module with a single data type in it.  We also built a custom MVC controller widget that's responsible for the presentation of the custom module's data type items.  This widget appears in the toolbox and we've added it to a page.  The widget provides list and detail views on the same page. 

    However, when we're editing these custom data type items using the backend admin interface, the Preview button reports "No pages has been set to display content like this."

    How do we make the association between our custom data type and the MVC widget we use to present them so that this feature will properly link to the page hosting an instance of the widget?

    Thanks.
  2. Dimitri Cools
    Dimitri Cools avatar
    80 posts
    Registered:
    29 Sep 2016
    28 Apr
    Link to this post
    Hi, 

    By default Sitefinity uses the IContentLocatableView interface implemented on the out of the box content widgets in order to track their locations on different pages. This interface powers the Preview functionality from the content modules as well as the Search indexing and the correct resolving of the links in it. 
    When you click on the Preview button of a built-in content item, Sitefinity searches the page where you have placed the module's widget and then renders the item on its details page.

    Regarding custom controls, the Preview functionality will work only if these controls implement the IContentLocatableView interface. Implementing this interface in your control will basically tell the Preview button where this type of content is placed on the site and will redirect to this location in order to display the content.

    After you implement the IContentLocatableView interface in your MVC controllers, the Preview button will redirect to the url of the module's details page. 

    Please refer to the documentation for more details:
    Register content location with your custom widgets
    http://docs.sitefinity.com/for-developers-register-content-location-with-your-custom-widgets


    Locations of content items
    http://docs.sitefinity.com/for-developers-locations-of-content-items

    Here is also a sample code for your convenience on how this interface is implemented for dynamic module. You can further modify this on your end and make it to work for the content type you need:
     
    public bool? DisableCanonicalUrlMetaTag
           {
               get;
               set;
           }
       
           public IEnumerable<IContentLocationInfo> GetLocations()
           {
               var location = new ContentLocationInfo();
       
               Type testType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Test.Test");
               location.ContentType = testType;
       
               var manager = DynamicModuleManager.GetManager();
               var providerName = manager.Provider.Name;
               location.ProviderName = providerName;
       
               yield return location;
           }


    Regards,
    Dimitri Cools
    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
     
    Answered
  3. Eric
    Eric avatar
    5 posts
    Registered:
    14 May 2015
    28 Apr in reply to Dimitri Cools
    Link to this post
    That sounds like just the ticket, thanks!  I had seen that interface as it relates to search, but didn't realize there was a relationship between it and locating controllers for custom content preview.  I will give it a try and if/when it works I'll come back and mark this answered.  Thanks again.
3 posts, 1 answered