Dynamicweb 8 Documentation
ContentModule Class
Members  Example 

Responsible for outputting the HTML for your module in the frontend. A module can be attached to a paragraph in the administration. ContentModule is responsible for having the paragraph return some module output. Inherit this class and override the GetContent method to return the HTML for the module as a string.
Object Model
ContentModule ClassPageView ClassProperties Class
Syntax
'Declaration
 
Public MustInherit Class ContentModule 
public abstract class ContentModule 
Remarks
The class created by inheriting ContentModule needs and attribute AddInName with a module system name specified. The module system name needs to be a-z and 0-9 and no spaces etc.
Example
How to inherit ContentModule and override GetContentHow to inherit ContentModule and override GetContent
using Dynamicweb.Extensibility;

namespace Dynamicweb.Examples.CSharp
{
    [AddInName("ModuleSystemName")]
    public class Frontend : ContentModule
    {
        public override string GetContent()
        {
            //Get an instance of a template object
            var template = new Dynamicweb.Rendering.Template("ModuleSystemName/Template.html");

            //Set a tag named "Text" with the value from the HelloText property
            template.SetTag("Text", Properties.Values["HelloText"].ToString());

            //Add a tag with the system name of the module. That would be the same as in the [AddInName()] attribute
            template.SetTag("ModuleSystemName", this.ModuleSystemName);

            //Add the page id executing the page with the paragraph where this module is attached
            template.SetTag("PageID", this.Pageview.ID);

            //Return the parsed template to the event handler
            return template.Output();
        }
    }
}
Imports Dynamicweb.Extensibility

Public Class ContentModuleSample
    <AddInName("ModuleSystemName")> _
    Public Class Frontend
        Inherits Global.Dynamicweb.ContentModule

        Public Overrides Function GetContent() As String
            'Get an instance of a template object
            Dim template As Global.Dynamicweb.Rendering.Template = New Global.Dynamicweb.Rendering.Template("ModuleSystemName/Template.html")

            'Set a tag named "Text" with the value from the HelloText property
            template.SetTag("Text", Properties.Value("HelloText"))

            'Add a tag with the system name of the module. That would be the same as in the <AddInName()> attribute
            template.SetTag("ModuleSystemName", Me.ModuleSystemName)

            'Add the page id executing the page with the paragraph where this module is attached
            template.SetTag("PageID", Me.Pageview.ID)

            'Return the parsed template to the event handler
            Return template.Output()
        End Function
    End Class
End Class
Inheritance Hierarchy

System.Object
   Dynamicweb.ContentModule
      Dynamicweb.eCommerce.Frontend.Cart.Frontend
      Dynamicweb.eCommerce.Frontend.Frontend
      Dynamicweb.Modules.DataManagement.FormFrontend
      Dynamicweb.Modules.DataManagement.PublishingFrontend
      Dynamicweb.Modules.UserManagement.Frontend

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ContentModule Members
Dynamicweb Namespace

Send Feedback