FA99D6C325AF46CEA30155D219CAF3F9
  • Archiv
  • 10.04.2018
  • EN

WSM blog: Developing Custom RenderTags

written by Dennis Reil, 29. June 2011
 

Did you ever think of implementing your own RenderTag to ease up template development? 
Management Server already provides everything you need for that task. There was only one small bug that was actually blocking the load mechanism of custom RenderTags. This was fixed for version 11 now and will soon be available in one of the next hotfixes for 10.1 SP2.

Here are the steps to develop your own RenderTag:

  1. Open up Visual Studio and create a new class library project, e.g. My.CustomRenderTag
  2. Add references to Reddot.CMS and Reddot.CMS.Rendering
  3. Now add a new class and implement the Reddot.CMS.Rendering.IRenderTag interface, e.g. HelloWorldRenderTag:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Reddot.CMS.Rendering.Tags;
using Reddot.CMS.Rendering.Objects;
using System.Xml;
using Reddot.CMS.Rendering;
namespace My.CustomRenderTag
{
    public class HelloWorldRenderTag : IRenderTag
    {
        public HelloWorldRenderTag()
        {
        }
        public void Render(RenderStream outputStream, TagProcessor tagProcessor, XmlNode tag, ObjectLoadManager objectLoadManager, PageBuildContext context)
        {
            string text = tag.InnerText;
            if (string.IsNullOrEmpty(text))
            {
                outputStream.WriteLine("Hello World!");
            }
            else
            {
                outputStream.WriteLine("Hello {0}!", tag.InnerText);
            }          }
    }
}
  1. Build the project
  2. Adapt the main.config in your ASP directory:
    add the following line in the <RenderTag>-section:
<RenderTags>
      <Tag name="helloworld" typename="HelloWorldRenderTag" namespace="My.CustomRenderTag" filename="<PathToAssembly>\My.CustomRenderTag.dll" />
  1. Kill the RDCMSServiceProcess.exe
  2. Now add your new RenderTag (<helloworld>) to your template

Source: Developing Custom RenderTags

© copyright 2011 by Dennis Reil

       

Downloads

 

QuickLinks

 

Channel