2

我们可以在哪里找到用户生成评论项目的默认 .net tbb代码。如果有人可以提供任何其他示例代码,那就太好了。

提前致谢。

4

3 回答 3

10

要插入 UGC 注释,您需要添加 TCDL 标记、JSP 标记库标记或 ASP.NET 服务器控件,它们将在内容交付端解析。

  • ASP.NET 服务器控件<ugc:Comments runat="server">
  • JSP 自定义标签 <ugc:Comments>
  • TCDL 标签 <tcdl:Comments>

我建议您查看带有 2011 文档的 sdllivecontent 门户(需要登录)。您将在那里找到所有 UGC 命令的列表。

于 2012-08-10T07:36:48.770 回答
4

默认UGC TBB代码,希望对你有用。

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);
            }
        }
    }
}
于 2012-08-22T02:20:18.353 回答
1

您在服务器上安装 Tridion 时是否安装了用户生成的内容?

于 2012-08-11T12:26:22.177 回答