首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >默认UGC tbb代码

默认UGC tbb代码
EN

Stack Overflow用户
提问于 2012-08-10 05:10:56
回答 3查看 292关注 0票数 2

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

提前谢谢。

EN

回答 3

Stack Overflow用户

发布于 2012-08-10 07:36:48

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

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

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

票数 10
EN

Stack Overflow用户

发布于 2012-08-22 02:20:18

默认的UGC TBB代码,希望对您非常有用。

代码语言:javascript
复制
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);
            }
        }
    }
}
票数 4
EN

Stack Overflow用户

发布于 2012-08-11 12:26:22

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11895812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档