Summary

This article explains the steps involved in creating and registering custom pages in Incentive 2.x.
Use custom pages when the default page types don’t fit your needs. For example when you need to structure user input in a specific way or when you want to present information from other systems.

There are 3 steps involved when creating a custom page.

  1. Create the user control that renders the custom page.
  2. Register the control in the settings file.
  3. Define where the custom page should be visible.

 

Creating the control that renders the custom page

Incentive uses ASP.NET user controls to render a custom page. The user control is responsible for rendering the custom page and for handling user input.

The user control must inherit from Mindroute.Incentive.Web.Site.UI.CustomPageBase and must implement the methods GetContent and SetContent.

There are two different approaches when creating the user control. Either one control renders the custom page in both edit and view mode or you separate the rendering into two different controls (e.g. CustomPageView.ascx and CustomPageEdit.ascx).

Below is a simple example of a user control that saves a name and a phone number.

[UserInformation.ascx]

<Control Language="vb" AutoEventWireup="false" CodeFile=" UserInformation.ascx.vb" Inherits="Mindroute.Incentive.Web.Site.UI.CustomPage.UserInformation" />
<incentive:FormBodyItem id="lblName" runat="server">
    <asp:TextBox id="txtName" runat="server"></asp:TextBox>
</incentive:FormBodyItem>
<incentive:FormBodyItem id="lblPhone" runat="server">
    <asp:TextBox id="txtPhone" runat="server"></asp:TextBox>
</incentive:FormBodyItem>

 

[UserInformation.ascx.vb]

Namespace Mindroute.Incentive.Web.Site.UI.CustomPage
   Partial Public Class UserInformation
      Inherits CustomPageBase
      Public Overrides Sub GetContent()
         txtName.Text = NodeXmlValue("name")
         txtPhone.Text = NodeXmlValue("phone")
      End Sub

      Public Overrides Function SetContent(ByRef Message As String) As Boolean
         Dim result As Boolean
         'Validate the name
         If String.IsNullOrEmpty(txtName.Text) Then
            Message = "You have to specify a name."
            result = False
         Else
            NodeXmlValue("name") = txtName.Text
            NodeXmlValue("phone") = txtPhone.Text
            result = True
         End If
         Return result
      End Function

      Public Overrides Sub AfterUpdate(ByVal UpdatedContent As Model.Content)
         MyBase.AfterUpdate(UpdatedContent)
      End Sub
   End Class
End Namespace

 

A user control is created that inherits from CustomPageBase and defines two ASP.NET Textbox controls, name and phone number. The methods SetContent and GetContent are overridden and we use these methods to populate the textboxes and to save the values.

Note that a simple validation function has been implemented that returns an error message if the name is empty. If SetContent returns false all further processing of the page will be stopped and the page will not be saved allowing the user to correct their input.

Please make sure that the build action for both the ascx-file and the codebehind-file is set to “Content”. Otherwise your build will fail.
Place the user control in the directory public\custompage\ and any local resources you may need in \public\custompage\App_LocalResources.

 

Registering the custom page

Open the file “\app_data\settings\custompage.xml” and add a new page element and specify the attributes:

  • id [Mandatory]: A unique identifier for the custom page.
  • control  [Mandatory]: The path to the user control.
  • enable  [Mandatory]: Enter “1” for enabled and “0” for disabled.
  • publiccontrol [optional]: The path to the user control that renders the custom page in view mode only.
  • type [optional]: Where the custom page should be available. Possible values are “blog” and “wiki”.

Add localized description and name for the custom page.

Example:
<pages>
    <page id="kb_article" control="~/public/custompage/kbarticle.ascx" enable="1" type="wiki">
        <name lang="en" description="A knowledgebase article page.">KB article</name>
        <name lang="sv" description="En sida i en kunskapsdatabas.">KB-artikel</name>
    </page>
</pages>

 

Define where the custom page should be visible

Define if the custom page should be visible for a certain page by selection the option “Customize create menu” in the “Create” section for an article. See below.

 

There are no comments on this page.
create_menu.jpg
   
 

Incentive Online Help

Welcome to the online help of Incentive! This help is built as a wiki and invites you to collaborate and make the content better.