help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Customize Overview Pages in AxCMS.net

You customize a standard overview by creating your own overview helper class and/or filter control and registering them in web.config.

Since version 7.1.4 AxCMS.net comes with and extendable approach for the overview pages. This document describes, how to customize the existing AxCMS.net overview pages. If you are interested in creating your own overview page from scratch, please check Creating Custom Overview Pages for more information.

General

Every overview page has a controller responsible for the overview behaviour - so called OverviewHelper. You can provide a standard overivew page with your custom helper, which you inherit from the standard one and override the methods which you need to customize.

Additionally you can provide your own ASCX-control which should be used as a filter.

You configure both with the web.config - section OverviewPages. Let's assume we want to customize the standard PagesOverview page in this example. Then we should start with changing the configuration file the following way:


<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
...
<section
name="OverviewPages"
type="Axinom.AECMS.OverviewPagesSectionHandler, AxCMS.BL" />
</configSections>

...

<OverviewPages>
...
<OverviewPage
Name="PagesOverview"
Assembly="AxCMSExtras_MyProject"
Helper="MyProject.Extras.MyPagesOverviewHelper"
Filter="../../Extras/MyPagesFilter.ascx" />
</OverviewPages>

...

</configuration>

Now MyPagesOverviewHelper will be used as a helper for PageOverview and MyPagesFilter.ascx will replace the standard filter.

Brief explanation of the attributes in the element OverviewPage:

  • Name - must be the name of the overview page you would like to customize (see below for the list of available overviews);
  • Assembly - the name of the assembly where the your custom helper class is located (see below for more details);
  • Helper - the full class name of your custom helper;
  • Filter - the path to your custom filter control relative to the overview page you are customizing (see below for more details).

Customizing Overview Helper

The following chapter will demonstrate how to customize the existing columns on the PagesOverview page.

Please complete the following steps:

1. Create your custom helper file for the PagesOverview

The PagesOverview will have its own helper file, but you can easily override it with your own custom one. Please create your custom helper file in the Extras project of your solution and inherit it from AxCMS.AxCMSweb.admin.pages.AxPageOverviewHelper:
public class MyPagesOverviewHelper : AxCMS.AxCMSweb.admin.pages.AxPageOverviewHelper
{
 ...
}

Please see the General section above about how to register your custom helper for PagesOverview page.

2. Override relevant members in your custom helper class

There are plenty of members in the helper class to override. Please see here (the step 5) for more information about that.

After completing these steps, you will have your own customized pagesOverview page with the columns you want to display.

To add a column you need to override and extend the methods GetColumnWidth(), GetColumnNames(), GetHeaderContent(), GetSortOptions().

To add custom CmsActivites (buttons in the left column), override the method Operations() like in this example:

protected override string[] Operations()
{
  return new string[] {"publishPage", "delete", "lock"};
}

Each string in the array is a name of a CmsActivity. CmsActivity with this name must already exisit. Read CmsActivites for more infomation.

Customizing Filter

The following chapter will show how to customize the existing filter on an overview page.

Please complete the following steps:

1. Create your custom FilterParameters class

Each filter has its own FilterParameters class which is derived from the class Axinom.AECMS.FilterParameters (or from one of its descendants). Let's assume in the context of current PagesOverview customizing example, that we want to extend the current PagesOverview filter with one extra checkbox - "Return nothing" (you will never know when you need such kind of stuff ;).

So let us create MyPagesFilterParameters and add necessary code for achieving our goal:
[Serializable]
public class MyPagesFilterParameters : AxPageBaseFilterParameters
{
public MyPagesFilterParameters() : base() { } //to be able to copy content from base class public MyPagesFilterParameters(AxPageBaseFilterParameters filterParams) : base()
{
if (filterParams != null)
{
this.Name = filterParams.Name;
this.Template = filterParams.Template;
this.Author = filterParams.Author;
this.FilterMode = filterParams.FilterMode;
this.Category = filterParams.Category;
this.PublicationStateList = filterParams.PublicationStateList;
this.CheckedOut = filterParams.CheckedOut;
this.CurrentUserID = filterParams.CurrentUserID;
this.OnlyMyStuff = filterParams.OnlyMyStuff;
this.OnlyToRequestPublishing = filterParams.OnlyToRequestPublishing;
this.OnlyToPublish = filterParams.OnlyToPublish;
this.OnlyToApprove = filterParams.OnlyToApprove;
}
}

private bool _returnNothing = false;

public bool ReturnNothing
{
get
{
return _returnNothing;
}
set
{
_returnNothing = value;
}
}

public override void ApplyToQuery(DbSelectQuery query, int skipFirst, string sort)
{
base.ApplyToQuery(query, skipFirst, sort);
if(ReturnNothing)
{
query.AddWhere("1 = 0");
}
//if you have added new sort options in your grid, //then add them here too to query
}
public override void SetEmpty()
{
base.SetEmpty();
_returnNothing = false;
}
}

As you see, we have created a new property "ReturnNothing" (for the new checkbox on the filter control's ASCX page) and then we have overridden the ApplyToQuery() method. That method is meant for composing the query object which will be used to derive SQL statement for the SQL server. All we did here was that we just added our own where-clause to the query.

Please note: the FilterParameters class MUST have attribute [Serializable], because it will be sent over webservice when needed.

2. Create your custom filter for PagesOverview

The filter file must be a standard Web UserControl (the ASCX file). The codebehind of that control must be inherited from AxCMS.AxCMSweb.admin.templates.BaseFilter or from one of its descendants. Let us create the MyPagesFilter control and derive it from the AxCMS.AxCMSweb.admin.pages.PagesFilter class:
public class MyPagesFilter : AxCMS.AxCMSweb.admin.pages.PagesFilter
{
protected CheckBox returnNothingCheckbox;

public override void DataBind(FilterParameters filterParams)
{
base.DataBind(filterParams);
MyPagesFilterParameters filterParameters = filterParams as MyPagesFilterParameters;
if(filterParameters!=null)
{
returnNothingCheckbox.Checked = filterParameters.ReturnNothing;
}
}

public override FilterParameters CreateFilterParameters()
{
return new MyPagesFilterParameters();
}

public override FilterParameters ReadFilterParameters()
{
AxPageBaseFilterParameters filterParameters = (AxPageBaseFilterParameters)base.ReadFilterParameters();
MyPagesFilterParameters sampleFilterParameters = new MyPagesFilterParameters(filterParameters);
if(this.Mode == FilterMode.General)
{
filterParameters.ReturnNothing = returnNothingCheckbox.Checked;
}
return filterParameters;
}

public override FilterParameters CreateDefaultFilterParameters()
{
return new MyPagesFilterParameters();
}
}

There are plenty of other methods to override available at the BaseFilter class. I will comment some of them below (please see the inline documentation for more information):
* DataBind() - Sets up the filter form element values based on information available at the FilterParameters object.
* CreateFilterParameters() - Creates the FilterParameters object.
* ReadFilterParameters() - Sets up the FilterParameters object with values from the filter form elements.
* CreateDefaultFilterParameters() - Creates the FilterParameters object with default state.

Now, when we have the codebehind of the MyPagesFilter, let us also define the ASCX file for it.
I am not going to display all the content of MyPagesFilter.ascx, because it is all seen from the AxCMS.net solution too, just one thing to note - we should add ASP.NET checkbox for our extra property we defined:
<asp:Panel ID="_generalPanel" Runat="server" DefaultButton="_applyGeneralFilterButton">
<Ax:AxinomPanel id="filtergeneralPagesPanel" runat="server" Headline="Filter" width="100%" CssClass="keyarea">
...
<tr>
<td align="left">
<asp:CheckBox runat="server" ID="returnNothingCheckbox" Text="Return nothing" />
</td>
</tr>
...

</Ax:AxinomPanel>
</asp:Panel>
...

As the final part of that step, please make sure the corresponding OverviewPage-section in web.config file specifies the right path to the custom filter of PagesOverview.

After completing the previous steps, you have successfully customized the PagesOverview filter.

List of the AxCMS.net overview pages where the filter can be customized:

The following overview pages are taking advantage of the new approach of composing queries (filter parameters for those overview pages are specified after the overview pages names):
* Release Overview - AxCMS.AxCMSweb.admin.checkout.ReleaseFilterParameters
* Documents overview - Axinom.AECMS.document.AxDocumentFilterParameters
* Flash Overview - Axinom.AECMS.Flash.AxFlashFilterParameters
* Language Overview - Axinom.AECMS.language.AxLanguageOverviewTableFilterParameters
* Root Language Overview - Axinom.AECMS.language.AxLanguageRootFilterParameters
* Links Overview - Axinom.AECMS.Links.LinksFilterParameters
* Pages Overview - Axinom.AECMS.page.AxPageBaseFilterParameters
* Newsletter Overview - Axinom.AECMS.page.AxPageBaseFilterParameters
* Mailtemplates Overview - Axinom.AECMS.page.AxPageBaseFilterParameters
* MS Users Overview - Axinom.AECMS.UserManagement.AxUserFilterParameters
* LS Users Overview - Axinom.AECMS.UserManagement.AxUserFilterParameters