我是Tridion开发的新手,我有第一个"基本"问题。我已经在TBB(使用Content Manager Text Editor)中写了一个简单的C#代码片段,并且我尝试使用引擎,软件包和日志字段(我知道它们可以通过Tridion提供),但我收到一个错误,说"该名称在上下文中不存在"。这是代码:
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<div>
<!-- TemplateBeginRepeat name="Component.Fields.crociera" -->
<!-- TemplateBeginIf cond="prezzo<250" -->
Go to @@location@@<br/>
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->
</div>
<%
String ts = DateTime.Now.ToString("d MMM yyyy");
Response.Write("<br/>"+ts);
engine.getSession();
%>
保存TBB并发布页面时,我会收到此错误:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'engine' does not exist in the current context
Source Error:
Line 31: Response.Write("<br/>"+ts);
Line 32: engine.getSession();
Line 33: %>
Line 34: </div>
Source File: c:inetpubwwwrootstagepjricercaricerca.aspx Line: 32
可能我想念某件事或做错了什么,有人知道这个问题吗?
您使用的Engine
对象是Tridion的Tom.net API的一部分,该对象仅在发布该项目时可用于代码。
ASPX页面到达前端服务器后,Tom.net API将不再可用。这样做的一部分原因是,Tridion Content Manager根本不再可以从您的Web服务器找到。
您不必通过其TOM.NET API对Tridion Content Manager进行编程,而是需要通过其API进行编程,以防止Tridion内容交付。您可以在实时文档中找到常见案例的文档(登录所需)。
您可以找到有关如何正确创建C#片段的信息,以在C#TBB中添加用户定义的方法(C#代码片段)?