Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Create a new module in Site Module for CMS Desk View modes: 
User avatar
Member
Member
gan_kim_heng-hotmail - 3/11/2012 10:36:27 AM
   
Create a new module in Site Module for CMS Desk
Create a customized table for e-commerce.
need code changes in "<root>\CMSModules\Ecommerce\Pages\Tools\Configuration\ZoneClasses\ZoneClass_List.aspx"

<grid>
<actions>
<action name="edit" caption="$General.Edit$" icon="Edit.png" />
<action name="delete" caption="$General.Delete$" icon="Delete.png" confirmation="$General.ConfirmDelete$" />
</actions>
<columns>
<column source="ZoneClassDisplayName" localize="true" caption="$general.name$" wrap="false">
<filter type="text" />
</column>

<column width="100%"></column>
</columns>
<objecttype name="ecommerce.zoneclass" />
<options>
<key name="DisplayFilter" value="true" />
</options>
</grid>


Seems like need to insert a record in:

Select * from CMS_CLass with (nolock)
where CLassname = 'ecommerce.zoneclass'

Are those value need in the columns "ClassXMLSchema" & "ClassFormDefinition" have to be manually created, instead on some UI to configure?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/12/2012 3:32:05 AM
   
RE:Create a new module in Site Module for CMS Desk
Hi,

do you need to customize UI in way that Configuration section contains your custom module data? If so, please take a look here:
Code customization
UI customization
need code changes in "<root>\CMSModules\Ecommerce\Pages\Tools\Configuration\ZoneClasses\ZoneClass_List.aspx

I could not find this file in a default installation of Kentico. Is it your custom file?

ecommerce.zoneclass -> Is it your custom table class name? If so, ClassXMLScheme and ClassFormDefinition are generated automatically, they are changed in case you insert/delete/update a new field to your custom table. There an API which regenerate the schema, but I am not sure if it is what you need:


// Update XML schema
DataClassInfo class = DataClassInfoProvider.GetDataClass("class.codename");
class.ClassXmlSchema = TableManager.GetXmlSchema("class.codename");
CMS.SettingsProvider.DataClassInfoProvider.SetDataClass(class);

// Generate queries
DataEngine.SqlGenerator.GenerateDefaultQueries("class.codename", true, false);


Best regards,
Ivana Tomanickova


User avatar
Member
Member
gan_kim_heng-hotmail - 3/12/2012 10:15:09 AM
   
RE:Create a new module in Site Module for CMS Desk
Thanks for the reply.

do you need to customize UI in way that Configuration section contains your custom module data? If so, please take a look here:
Code customization
UI customization

i think these 2 links are more to customprovider & werb-parts, etc

I could not find this file in a default installation of Kentico. Is it your custom file?

ecommerce.zoneclass -> Is it your custom table class name?

yes, those are mine

If so, ClassXMLScheme and ClassFormDefinition are generated automatically, they are changed in case you insert/delete/update a new field to your custom table. There an API which regenerate the schema, but I am not sure if it is what you need:

when the system will use the data in those columns?


NOw i ma looking at this file: <root>\CMSAdminControls\UI\UniGrid\UniGrid.ascx.cs
when the ObjectType is assigned,

private void LoadObjectTypeDefinition(XmlNode objectTypeNode)
{
if (objectTypeNode != null)
{
ObjectType = objectTypeNode.Attributes["name"].Value;

// Set the columns property if columns are defined
LoadColumns(objectTypeNode);
}
}


then I saw "InfoObject" that needed below was initialized as well (for those taxclass, etc; but not my zone-class in the debugger;

public override DataSet RetrieveData()
{
DataSet ds = null;

// If datasource for unigrid is query (not dataset), then execute query
if (!string.IsNullOrEmpty(Query))
{
// Reload the data with current parameters
ds = ConnectionHelper.ExecuteQuery(Query, QueryParameters, CompleteWhereCondition, CurrentOrder, TopN, Columns, CurrentOffset, CurrentPageSize, ref pagerForceNumberOfResults);
}
// If UniGrid is in ObjectType mode, get the data according to given object type.
else if (InfoObject != null)
{
// Get the result set
ds = InfoObject.GetData(QueryParameters, CompleteWhereCondition, CurrentOrder, TopN, Columns, false, CurrentOffset, CurrentPageSize, ref pagerForceNumberOfResults);
}


but reflector only shows:

namespace CMS.UIControls
{
[ParseChildren(true)]
public abstract class UniGri

....
public void set_ObjectType(string value)
{
this.mObjectType = value;
this.mInfoObject = null;
}

User avatar
Member
Member
gan_kim_heng-hotmail - 3/12/2012 11:30:33 AM
   
RE:Create a new module in Site Module for CMS Desk
or do i have to create these 2 classes in AppCode?

ZoneClassInfo.cs
namespace CMS.Ecommerce
{
/// <summary>
/// Summary description for ZoneClassInfo
/// </summary>
public class ZoneClassInfo : SynchronizedInfo<ZoneClassInfo>
{
/// <summary>
/// Type information.
/// </summary>
public static TypeInfo TYPEINFO;

static ZoneClassInfo()
{
TypeInfo info = new TypeInfo(typeof(ZoneClassInfoProvider), "ecommerce.zoneclass", "ECommerce.ZoneClass", "ItemID", "ItemModifiedWhen", "ItemGUID", "ZoneName", "ZoneDisplayName", null, "", null, null);
info.ChildObjectTypes = "";
...
}

public ZoneClassInfo()
: base(TYPEINFO)
{

}

public ZoneClassInfo(DataRow dr)
: base(TYPEINFO, dr)
{
}

public override bool CheckPermissions(PermissionsEnum permission, string siteName, IUserInfo userInfo)
{
switch (permission)
{
case PermissionsEnum.Read:
return ECommerceHelper.IsUserAuthorizedForPermission("ConfigurationRead", siteName, (UserInfo) userInfo);

case PermissionsEnum.Modify:
case PermissionsEnum.Create:
case PermissionsEnum.Delete:
return ECommerceHelper.IsUserAuthorizedToModifyConfiguration(this.IsGlobal, siteName, (UserInfo) userInfo);
}
return base.CheckPermissions(permission, siteName, userInfo);
}

public void CopyDataFrom(ZoneClassInfo zoneClass)
{
if (zoneClass != null)
{
this.ZoneClassDisplayName = zoneClass.ZoneClassDisplayName;
this.ZoneName = zoneClass.ZoneName;
}
}

protected override void DeleteObject()
{
ZoneClassInfoProvider.DeleteZoneClassInfo(this);
}

protected override void SetObject()
{
ZoneClassInfoProvider.SetZoneClassInfo(this);
}


public virtual string ZoneClassDisplayName
{
...
}

public virtual Guid ItemGUID
{
...
}

public virtual int ItemID
{
...
}

public virtual DateTime ItemModifiedWhen
{
...
}

public virtual string ZoneName
{
...
}
}
}


ZoneClassInfoProvider.cs

namespace CMS.Ecommerce
{
/// <summary>
/// Summary description for ZoneClassInfoProvider
/// </summary>
public class ZoneClassInfoProvider : AbstractInfoProvider<ZoneClassInfo, ZoneClassInfoProvider>
{
public ZoneClassInfoProvider()
: base(true, true, false, LoadHashtableEnum.None)
{
//
// TODO: Add constructor logic here
//
}

/// <summary>
/// Checks zone class dependencies. Returns true if the zone class is dependent.
/// </summary>
/// <param name="classId">Zone class ID</param>
public static bool CheckDependencies(int classId)
{
return AbstractInfoProvider<ZoneClassInfo, ZoneClassInfoProvider>.ProviderObject.CheckObjectDependencies(classId);
}

/// <summary>
/// Clears hashtables.
/// </summary>
/// <param name="logTasks">If true, web farm tasks are logged</param>
public static void Clear(bool logTasks)
{
AbstractInfoProvider<ZoneClassInfo, ZoneClassInfoProvider>.ProviderObject.ClearHashtables(logTasks);
}
...

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/19/2012 3:45:51 AM
   
RE:Create a new module in Site Module for CMS Desk
Hi,

to sum up.

Do you need to display custom table data in the unigrid control?

How to configure unigrid is described here:
Unigrid - getting started

In the code you may need to get your custom table data:
Get custom table data

Best regards,
Ivana Tomanickova

User avatar
Member
Member
gan_kim_heng-hotmail - 3/19/2012 10:59:34 AM
   
RE:Create a new module in Site Module for CMS Desk
thanks. I think I am roughly there.
Just left the CSS issue.

User image

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/22/2012 3:25:25 AM
   
RE:Create a new module in Site Module for CMS Desk
Hi,

unigrid has a cssclass atribute which you can be used to define css:
Unigrid configuration

Best regards,
Ivana Tomanickova