Default UGC tbb code

313 Views Asked by At

Where we can find the default .net tbb code for user generated comments project. Also it would be great if someone can provide any other sample code.

Thanks in advance.

3

There are 3 best solutions below

3
On

To insert UGC comments you need to add TCDL tags, JSP tag library tags or ASP.NET Server Controls that will be resolved on Content Delivery side.

  • ASP.NET Server Control <ugc:Comments runat="server">
  • JSP Custom Tag <ugc:Comments>
  • TCDL tag <tcdl:Comments>

I suggest you to take a look at the sdllivecontent portal with 2011 documentation (login required). You will find there list of all UGC commands.

0
On

Did you install User Generated Content when you installed Tridion on the server?

2
On

Default UGC TBB Code, I hope will be very usefull for you.

namespace Tridion.Ugc.Templating.DefaultTemplates
{
    using System;
    using Tridion.ContentManager;
    using Tridion.ContentManager.Templating;

    public static class Helper
    {
        public static ApplicationData GetApplicationData(Engine engine, Package package)
        {
            IdentifiableObject obj2 = engine.GetObject(package.GetByType(engine.PublishingContext.ResolvedItem.IsComponentPresentation ? ContentType.Component : ContentType.Page));
            ApplicationData data = obj2.LoadApplicationData("ugc:ComponentAndPage");
            if (data == null)
            {
                TemplatingLogger.GetLogger(typeof(EnableUgcProcessing)).Warning(string.Format("No UGC application data for {0} found, UGC output will be disabled", obj2.Id));
            }
            return data;
        }
    }
}



namespace Tridion.Ugc.Templating.DefaultTemplates
{
    using System;
    using System.Text;
    using System.Xml;
    using Tridion.ContentManager;
    using Tridion.ContentManager.Templating;
    using Tridion.ContentManager.Templating.Assembly;

    [TcmTemplateTitle("Enable User Generated Content Processing")]
    public class EnableUgcProcessing : ITemplate
    {
        public void Transform(Engine engine, Package package)
        {
            ApplicationData applicationData = Helper.GetApplicationData(engine, package);
            bool flag = false;
            bool flag2 = false;
            bool flag3 = false;
            bool flag4 = false;
            string innerText = null;
            string str2 = null;
            if (applicationData != null)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(Encoding.Unicode.GetString(applicationData.Data));
                XmlNode node = document.SelectSingleNode("*/allowtocomment");
                if (node != null)
                {
                    flag = XmlConvert.ToBoolean(node.InnerText);
                }
                node = document.SelectSingleNode("*/showcomments");
                if (node != null)
                {
                    flag2 = XmlConvert.ToBoolean(node.InnerText);
                }
                node = document.SelectSingleNode("*/allowtorate");
                if (node != null)
                {
                    flag3 = XmlConvert.ToBoolean(node.InnerText);
                }
                node = document.SelectSingleNode("*/showunmoderatedcomments");
                if (node != null)
                {
                    flag4 = XmlConvert.ToBoolean(node.InnerText);
                }
                node = document.SelectSingleNode("*/sortcomments/field");
                if (node != null)
                {
                    innerText = node.InnerText;
                }
                node = document.SelectSingleNode("*/sortcomments/direction");
                if (node != null)
                {
                    str2 = node.InnerText;
                }
            }
            Tridion.ContentManager.Templating.Item item = package.CreateStringItem(ContentType.Text, flag.ToString());
            package.PushItem("allowtocomment", item);
            item = package.CreateStringItem(ContentType.Text, flag2.ToString());
            package.PushItem("showcomments", item);
            item = package.CreateStringItem(ContentType.Text, flag3.ToString());
            package.PushItem("allowtorate", item);
            item = package.CreateStringItem(ContentType.Text, flag4.ToString());
            package.PushItem("showunmoderatedcomments", item);
            if (innerText != null)
            {
                item = package.CreateStringItem(ContentType.Text, innerText);
                package.PushItem("sortcommentsby", item);
            }
            if (str2 != null)
            {
                item = package.CreateStringItem(ContentType.Text, str2);
                package.PushItem("sortdirection", item);
            }
        }
    }
}