The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
In the previous post we have examined our possibilities for removing the unneeded functionality from the base Generic Content module. More often than not, however, we will need to add new functionality on top of the one provided in the base module.
Conceptually speaking, this is a tremendously simple task: we only need to add new Views. Once you have reused all the needed functionality, adding new functionality is like building a new module, except that you have of course saved yourself few months of work already.
To illustrate this approach we will take a look at the sample products module and see how we could add a feature for managing customers that buy products. Note that in this article we are going to examine only the approach and won’t implement the actual feature (such as UI, data persistence or business logic).
Our task is best illustrated by the following screenshot:
As you can see, all our reused Views are present, such as:
*** BEGIN NOTE ***
You may have noticed that good number of articles regarding the new backend architecture is actually demonstrating techniques that were explained in the overview of this topic. We believe that this fact is one of the biggest strengths of the new architecture. Namely, the basic concepts of the new architecture can be learned in several hours. From that point on, you will be developing solutions simply by applying these few fundamental approaches in different ways. That of course provides for a very flat learning curve as well as for the great reuse of the knowledge you already acquired.
*** END NOTE ***
In order to add new functionality to your Generic Content based module, all you need to do is create a new View and add it to the existing hierarchy. We can start by creating a new template for our CustomersView.
<%@ Control Language="C#" %> |
<%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %> |
<div class="ToolsAll"> |
<asp:PlaceHolder ID="fullWindow" runat="server"> |
</asp:PlaceHolder> |
<div class="clear"><!-- --></div> |
</div> |
<div class="workArea"> |
<h2>Customers view</h2> |
</div> |
using Telerik.Cms.Web.UI; |
namespace Telerik.Samples.Products.WebControls.Admin |
{ |
/// <summary> |
/// View for managing customers |
/// </summary> |
public class CustomersView : ViewModeControl<ProductsControlPanel> |
{ |
#region Properties |
[WebSysTemplate(CustomersView.customersViewTemplateName, "Products_Customers_Template", "/Products", false, "2009-03-23")] |
public override string LayoutTemplatePath |
{ |
get { return base.LayoutTemplatePath; } |
set { base.LayoutTemplatePath = value; } |
} |
protected override string LayoutTemplateName |
{ |
get { return CustomersView.customersViewTemplateName; } |
} |
#endregion |
#region Private fields |
private const string customersViewTemplateName = "Telerik.Samples.Products.Resources.ControlTemplates.Backend.CustomersView.ascx"; |
#endregion |
} |
} |
The final piece of the puzzle is to add this View to the existing View hierarchy of our Products module.
/// <summary> |
/// Loads configured views. |
/// </summary> |
protected override void CreateViews() |
{ |
AddView<ProductsView>("ProductsView", "ProductsView_Title", "ProductsView_Description", "all", Messages.ResourceManager); |
AddView<ProductsCategoriesView>("ProductsCategoriesView", "CategoriesView_Title", "CategoriesView_Description", "all", Messages.ResourceManager); |
AddView<ProductsTagsView>("ProductsTagsView", "TagsView_Title", "TagsView_Description", "all", Messages.ResourceManager); |
AddView<ProductsCommentsView>("ProductsCommentsView", "CommentsView_Title", "CommentsView_Description", "all", Messages.ResourceManager); |
AddView<ProductsPermissionsView>("ProductsPermissionsView", "PermissionsView_Title", "PermissionsView_Description", "globalPerm", Messages.ResourceManager); |
AddView<CustomersView>("CustomersView", "Customers", "From here you can manage all the customers of your store.", "all", null); |
} |
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.