help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Creating custom objects in AxCMS.net

You can extend AxCMS.net with your custom objects. AxCMS.net Framework allows you to re-use all the features available in AxCMS.net for your objects - persistence, categoris, relations, publishing, etc.

While developing AxCMS.net applications, often it is needed to create your own data objects, e.g. products for shop or events for event calendar. While some of the requirements can be covered with extending AxPage or other standard CMS classes, sometimes it is not enough. Luckily, AxCMS.net provides support for these custom requirements.

Database

You are responsible for the tables you need for your custom objects (or elements as CMS calls them). For AxCMS.net, you need to register your new element type in AxElementType table, which contains following fields:

  • ElementType - ID of your element type (under 50 is reserved for AxCMS.net use)
  • Name - name for your element type for development purposes
  • Text - translatable user-friendly name for your element type
  • BaseURL - URL for detail page (see User Interface below), use {0} for ID parameter, e.g. admin/pages/PagesDetail.aspx?AxID={0}
  • OverviewURL - URL for overview page (see User Interface below)
  • HomeSystem - does your element exist only in Management System (8 - e.g. MS user), only in Live System (2 - e.g. LS user) or it is created in MS and then published to LS (1 - e.g. Page)
  • TableName - name of table for your elements
  • IDColumnName - name of ID field in your table
  • NameColumnName - name of Name field in your table
  • RelationMode - elements in AxCMS.net can participate in relations with other elements (see AxRelation), this field specifies how (0 - element cannot be related, 1 - element is related from Management System, 2 - element is related from Live System)

Business Logic

You can use AxCMS.net persistence framework for mapping your business logic classes to database.

User interface

For the user interface in Live System you are responsible yourself. For example in order to output a list with all the products you need to load a product with adapter.LoadAll() and render it for with a Repeater.

For Management System, AxCMS.net provides possibilities to reuse overview/detail pages.

Accessing Live System elements

When you develop elements living in LS (HomeSystem is LiveSystem or 2) and you need to access them from Management System (e.g. to provide editor possibility to view/change them), it is recommended to access them with web service. You can place your web service to ExtraServices folder of your AxCMSPublishService virtual directory. See Extending WebServices.

Publishing MS/LS elements

When you develop elements created in MS and then published to LS (HomeSystem is ManagementSystem or 1), you need to create publishing mechanism to copy elements from MS to LS. There are two ways for doing this.

Pusher

You have to implement IPusher interface and register it in web.config:
<section name="Pusher" type="MyBL.MyPusher,MyBL" />

<Pusher />
Your pusher class will have Push method that accepts arbitrary dataset as parameter. You should process this dataset and add data to tables/files in Live System.
To start “pushing”, call on Management System side: new Publisher().Push(myDataSet);

Web service

More complex way but more flexible way is to add web service to ExtraServices project (see Accessing Live System elements). These web services work in Live System context and can be called from Management System. You have total flexibility of what to send to web service and how to process the data.