help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Extending Home Boxes

 

What is that all about?

Home Boxes are the boxes that appear on Home page after login into AxCMS.net. The user may always go to Home page by clicking "Home" in AxCMS.net toolbar.

There are 2 types of boxes available for home page:
    1. For creating new elements (Page, Document, Category)   
    2. For showing elements (Page, Document, Category)

These different kind of boxes have different configuration possibilities. This page describes how you can customize these Boxes for custom properties.

Configuration

There is an optional section named "HomePageBoxes" in the management system's web configuration file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
...
<section
name="HomepageBoxes"
type="Axinom.AECMS.usersettings.HomepageBoxesSectionHandler, AxCMS.BL"
/>
...
</configSections>
...

<HomepageBoxes>
<BoxCustomizations>
<BoxCustomization type="1">
<Namespace>MyProject.Extras.MyNewBoxParameters</Namespace>
<Assembly>AxCMSExtras_MyProject</Assembly>
</BoxCustomization>
<BoxCustomization type="2">
<Namespace>MyProject.Extras.MyListBoxParameters</Namespace>
<Assembly>AxCMSExtras_MyProject</Assembly>
</BoxCustomization>
</BoxCustomizations>
</HomepageBoxes>

...

</configuration>

Brief explanation:
* The section "HomePageBoxes" contains element "BoxCustomizations".
* "BoxCustomizations" contain elements named "BoxCustomization".
* It is possible to customize only one type of Box- define just one instance of XML element <BoxCustomization>.

BoxCustomization content:
The element has attribute named "type". Type can have values 1 or 2.
1 - For new element creation
2 - For listing existing elements
The element has 2 subelements: Namespace and Assembly
- Namespace - namespace of the class that is overriding corresponding CMS class;
- Assembly - the name of the assembly where the your custom overriding class is located (see below for more details);


Customizing New Box

For customizing New box, you have to override correct class, define bool parameter for Box Wizard and override validation logic.

1. Create overriding class

Create your class that is overriding Axinom.AECMS.usersettings.NewBoxParameters.

namespace MyProject.Extras
{
public class MyNewBoxParameters : NewBoxParameters
{
public MyNewBoxParameters ()
{ }

public MyNewBoxParameters (XmlNode node) : base(node)
{ }
...
}
}

2. Define bool type Property for Box configuration wizard

...
private bool _showMessage = false;
[CustomText("Message")]
[PropertyName("Message")]
[ElementType(ElementTypes.Page)]
public bool ShowMessage
{
get { return _showMessage; }
set { _showMessage = value; }
}
...

Attributes:
* CustomText - Text shown for this property.
* PropertyName - Name of extended property for corresponding object(in this case - AxPage is extended with property named "Message".
* ElementType - Defines, which types of element this property should be used for. [ElementType(ElementTypes.Page)] means, this property applies for Pages.

3. Override Validate method as desired

public override bool Validate(AxUser user, Box box, MessageCollection messages)
{
bool isValid = base.Validate(user,box,messages);
if (box.ElementType == ElementTypes.Page) // example of check,
{ //if it is Page box
...
}
...
return isValid;
}

Customizing List Box

List Box customizing is pretty similar to New Box customization, if you are customizing it for the same parameter. For List Box, it is more important to override Validate() method so, that your new checkboxes would also be validated.

1. Create overriding class

Create your new class for overriding Axinom.AECMS.usersettings.ListBoxParameters class. Define constructors for new class.

namespace MyProject.Extras
{
public class MyListBoxParameters : ListBoxParameters
{
public MyListBoxParameters() : base()
{}

public MyListBoxParameters (XmlNode node) : base(node)
{ }
...
}
}

2. Define bool type property for Box configuration wizard

...
private bool _showMessage = false;
[CustomText("Message")]
[PropertyName("Message")]
[ColumnName("Message", ElementTypes.Page)]
[ElementType(ElementTypes.Page)]
public bool ShowMessage
{
get { return _showMessage; }
set { _showMessage = value; }
}
...

Attributes:
* CustomText - Text shown for this property.
* PropertyName - Name of Extended property for corresponding object(in this case - AxPage is extended with property named "Message".
* ElementType - Defines, which types of element this property should be used for. [ElementType(ElementTypes.Page)] means, this property applies for Pages.
* ColumnName - Defines, which is the database field for sorting, if it is different from Property name. In this example, we define it just as an example for Page.

3. Override Validate method as desired

public override bool Validate(AxUser user, Box box, MessageCollection messages)
{
bool isValid = base.Validate(user,box,messages);
if (box.ElementType == ElementTypes.Page)
{
if (!isValid && !ShowMessage)
{
isValid = false;
}
}
...
return isValid;
}

You may need to use existing ListBox properties during validation. Use ListBoxParameters public properties for this purpose.
You should check also if number of columns doesn't exceed the MAXCOLUMNS constant defined in the same class.