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

Forums / Developing with Sitefinity / Exposing public properties in designer for custom News master control?

Exposing public properties in designer for custom News master control?

3 posts, 0 answered
  1. Ryan
    Ryan avatar
    57 posts
    Registered:
    07 May 2013
    12 May 2014
    Link to this post

    I've created a control that extends MasterListView for news content. Is it possible to expose public properties in this control through the designer view?

     Here is my control: http://i.imgur.com/BWW6hu1.png

    I was hoping to see these properties show up in this designer UI, but I don't see them: http://i.imgur.com/hthsPLe.png

     Is it possible to expose these properties? Thanks.

     

    UPDATE: Just to add details, I've followed the path of this post (http://www.sitefinity.com/developer-network/forums/sitefinity-sdk/extending-newsview) and mine is configured the same way. In my class that extends MasterListView, I have the two public properties that I wish to expose on the "advanced" section of the news widget designer. Right now, they don't display and am not sure why. I know the new view is being used, but the properties just aren't showing up. Thanks.

  2. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    21 May 2014
    Link to this post
    Hi Ryan,

    Our colleague, Junior, has suggested a solution in the support ticket you have opened about how you can expose public properties in the News widget designer.

    In order to achieve this, you need to create a class that inherits from ContentViewMasterDefinition and define your public properties in this class. The class may look like below:

    public class CustomMasterViewDefinition : ContentViewMasterDefinition
       {
           /// <summary>
           /// Initializes a new instance of the <see cref="MyNewsDefinition"/> class.
           /// </summary>
           public CustomMasterViewDefinition()
               : base(null)
           {
           }
      
           /// <summary>
           /// Initializes a new instance of the <see cref="MyNewsDefinition"/> class.
           /// </summary>
           /// <param name="configDefinition">The config definition.</param>
           public CustomMasterViewDefinition(ConfigElement configDefinition)
               : base(configDefinition)
           {
           }
      
           /// <summary>
           /// Gets or sets the test property
           /// </summary>
           [PropertyPersistence]
           public string TestProp { get; set; }
       }

    After that you need to create a class that inherits from ContentViewMasterElement and override the GetDefinition() method where you need to return your custom definitions. Here is a sample code:

    public class MyContentViewMasterElement : ContentViewMasterElement
     {
      
         public MyContentViewMasterElement(ConfigElement element)
             : base(element)
         {
         }
      
         public override Telerik.Sitefinity.Web.UI.DefinitionBase GetDefinition()
         {
             return new CustomMasterViewDefinition(this);
         }
     }

    Then, please build your project. The next step will be to go to Administration -> Settings -> Advanced -> System -> Type implementations mapping -> Telerik.Sitefinity.Web.UI.ContentUI.Config.ContentViewDefinitionElement -> Implementations and add a new implementation. According to the sample above, the implementation might be of type MyContentViewMasterElement.

    The last thing you need to do is to recreate the NewsFrontendList and make it to use your custom implementation. In order to do this, please go to Administration -> Settings -> Advanced -> News -> ...
    Then please copy all the settings and delete the NewsFrontendList. After that click the

    Regards,
    Stefani Tacheva
    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
     
  3. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    22 May 2014
    Link to this post
    Hello,

    In order to recreate the NewsFrontendList with your custom definitions, please go to Administration -> Settings -> Advanced -> News -> Controls -> NewsFrontend -> Views and click on NewsFrontendList and copy the settings. Another option is to open the page in another tab in order to be able to copy the settings when creating your own NewsFrontendList.

    Then please delete the NewsFrontendList and recreate it by clicking on the Create new button. Please select it to be of type MyContentViewMasterElement. Copy the settings from the old NewsFrontendList and save the changes.

    After performing this, you can drag the News widget on a page and open the widget in advanced mode by clicking on its Edit button and then click the Advanced button at the bottom of the window. Then click ControlDefinition -> Views -> NewsFrontendList and scroll down to see your custom property.

    Here is also a video (http://screencast.com/t/ueMV5qlB) for your convenience demonstrating the above steps.


    Regards,
    Stefani Tacheva
    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
     
3 posts, 0 answered