Creating the frontend definitions

You must wrap all of the frontend views in a ContentViewControlElement and return it in the DefineProductsFrontendContentView method of the definitions class. To do this, you must perform the following:

  1. Open the ProductsDefinitions.cs file.
  2. In the ProductsDefinitions class, implement the DefineProductsFrontendContentView method in the following way:

    public static ContentViewControlElement DefineProductsFrontendContentView(ConfigElement parent)
    {
        // define content view control
        var controlDefinition = new ContentViewControlElement(parent)
        {
            ControlDefinitionName = ProductsDefinitions.FrontendDefinitionName,
            ContentType = typeof(ProductItem)
        };
     
        // *** define views ***
        var productsListView = new ContentViewMasterElement(controlDefinition.ViewsConfig)
        {
            ViewName = ProductsDefinitions.FrontendListViewName,
            ViewType = typeof(MasterListView),
            AllowPaging = true,
            DisplayMode = FieldDisplayMode.Read,
            ItemsPerPage = 20,
            ResourceClassId = typeof(ProductsResources).Name,
            FilterExpression = DefinitionsHelper.PublishedOrScheduledFilterExpression,
            SortExpression = "PublicationDate DESC"
        };
     
        controlDefinition.ViewsConfig.Add(productsListView);
     
        var productsDetailsView = new ContentViewDetailElement(controlDefinition.ViewsConfig)
        {
            ViewName = ProductsDefinitions.FrontendDetailViewName,
            ViewType = typeof(ProductDetailsView),
            ShowSections = false,
            DisplayMode = FieldDisplayMode.Read,
            ResourceClassId = typeof(ProductsResources).Name
        };
     
        controlDefinition.ViewsConfig.Add(productsDetailsView);
        return controlDefinition;
    }

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK