This project is read-only.

Create your first module

Create a new folder in modules folder. The folder naming must follows this rules: namespace.modulename. Example PigeonCms.HelloWorld

Create module descriptor install.xml
<?xml version="1.0" encoding="utf-8" ?>
<install 
    installerVersion="1.0.0"
    type="module" 
    version="1.0.0" 
    core="true"
    namespace="PigeonCms"
    name="HelloWord"
    author="p-ice"
    creationDate="2013-01-28"
    copyright="Copyright(C) 2013 Your company Inc."
    license=""
    authorEmail="info@yourdomain.com"
    authorUrl="www.website.com"
    title="$ModuleTitle"
    description="$ModuleDescription"
    templateBlockName="Mainbody">
    <params>
		<param name="YourName" type="text" default="Barry White" label="Your name" description="type your name" />
		<param name="Gender" cssClass="" cssStyle="" type="combo" default="female" label="Gender" description="">
			<option value="not set" label="Not set"></option>
			<option value="male" label="Male"></option>
			<option value="female" label="Female"></option>
		</param>
		<param name="Age" type="text" default="0" label="Your age" description="" />
    </params>
</install>


Create views folder. This folder contains the user control(s) that manage module rendering. It is allowed to put different views (user controls).
Create a new user control. Ex: default.ascx
<%@ Control EnableViewState="false" Language="C#" AutoEventWireup="true" CodeFile="Default.ascx.cs" Inherits="Controls_HelloWord" %>
<div class='moduleBody modHelloWord <%=BaseModule.CssClass %>'>
    <%=LitOutput %>
</div>

This is easiest module structure. It only contins the output of a variable (LitOutput).

And now the code behind default.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Caching;
using PigeonCms;
using PigeonCms.Core.Helpers;

public partial class Controls_HelloWord: PigeonCms.BaseModuleControl
{
    //output var
    protected string LitOutput = "";

    private string yourName = "";
    /// <summary>
    /// string param from current module instance
    /// </summary>
    public string YourName
    {
        get { return GetStringParam("YourName", yourName); }
        set { yourName = value; }
    }

    private string gender = "";
    public string Gender
    {
        get { return GetStringParam("Gender", gender); }
        set { gender = value; }
    }

    private int age = 0;
    /// <summary>
    /// int param from current module instance
    /// </summary>
    public int Age
    {
        get { return GetIntParam("Age", age); }
        set { age = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //built-in cms cache manager
        var cache = new CacheManager<string>("PigeonCms.HelloWord");
        if (cache.IsEmpty(this.BaseModule.Id.ToString()))
        {
            LitOutput = "This is an HelloWord module.<br />"
            + "Theese are the params you set for the module; <br />"
            + "your name: " + this.YourName + "<br />"
            + "gender: " + this.Gender + "<br />"
            + "age: " + this.Age.ToString() + "<br />";
            cache.Insert(this.BaseModule.Id.ToString(), LitOutput);
        }
        else
        {
            LitOutput = cache.GetValue(this.BaseModule.Id.ToString());
        }
    }
}

Last edited Jan 28, 2013 at 1:13 PM by picce80, version 2