我们可以在哪里找到用户生成的评论项目的默认.net tbb 代码。如果有人可以提供任何其他示例代码,也会很棒。
提前致谢。
答案 0 :(得分:10)
要插入UGC注释,您需要添加将在Content Delivery端解析的TCDL标记,JSP标记库标记或ASP.NET服务器控件。
<ugc:Comments runat="server">
<ugc:Comments>
<tcdl:Comments>
我建议您查看sdllivecontent portal with 2011 documentation(需要登录)。 你会找到所有UGC命令的列表。
答案 1 :(得分: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);
}
}
}
}
答案 2 :(得分:1)
在服务器上安装Tridion时是否安装了用户生成的内容?