| lukezy 4/8/2008 2:52:19 PM |
Customization
|
DotShoppingCart CMS page is comprised by the server blocks, which are the pre-built server side controls. The out of box software comes with a handful of common blocks. The article is going to talk about creating your own server block.
1) Create the Standard ASP.NET stardard User Control and derive it from DotShoppingCart.OpenSource.Core.BlockUserControl
In the Page_Load method add the following code.
public partial class YourCustomControls : BlockUserControl {
protected void Page_Load(object sender, EventArgs e) {
EnableViewState = WebUtils.IsPageEditorEnable();
editor.BlockUserControl = this;
if (ShowEditor) {
pnlBlockContent.CssClass = "BlockEditPanel";
editor.BlockTitle = string.Format("Your Custom Control {0}", BlockId);
}
}
}
In the ascx file add the following code.
<%@ Register tagprefix="dsc" tagname="BlockEditor" src="/Controls/Blocks/BlockEditor.ascx" %>
<dsc:BlockEditor id="editor" runat="server" />
<asp:Panel id="pnlBlockContent" runat="server">
<%-- Place your control content here --%>
</asp:Panel>
A simple example is to check web\controls\blocks\Search.ascx and Search.ascx.cx files.
2) Hook up the new block in DB
Insert a new entry to dbo.DSC_Block_Type_lkp table e.g. INSERT INTO DSC_Block_Type_lkp (type, virtualPath) VALUES ('My Block', '/Controls/Blocks/MyBlock.ascx')
Insert a new entry to dbo.DSC_Block_Type_Group_Block_Type_Map