如何使用SDL Tridion TOM.NET API获取页面或组件的已发布时间戳
我试图使用TOM.NET API获取给定页面或组件到给定目标的已发布时间戳。在如何使用SDL Tridion TOM.NET API获取页面或组件的已发布时间戳,tridion,Tridion,我试图使用TOM.NET API获取给定页面或组件到给定目标的已发布时间戳。在页面或组件对象下,它不是很明显,有人能给我指出正确的方向吗?您可以使用PublishEngine.GetPublishInfo(IdentifiableObject)方法。为此,它返回保存日期和其他(publish)的PublishInfo对象的集合可用于给定项目的信息。多亏了巴特的上述回答,我已经完成了以下粗略代码。这与性能无关,因为这是向客户演示产品的概念证明: // if we are in publishing
页面
或组件
对象下,它不是很明显,有人能给我指出正确的方向吗?您可以使用PublishEngine.GetPublishInfo(IdentifiableObject)
方法。为此,它返回保存日期和其他(publish)的PublishInfo
对象的集合可用于给定项目的信息。多亏了巴特的上述回答,我已经完成了以下粗略代码。这与性能无关,因为这是向客户演示产品的概念证明:
// if we are in publishing mode, figure out the target we are publishing to, and get the timestamp that the page is published to this target
if (engine.PublishingContext.PublicationTarget != null)
{
ICollection<PublishInfo> publishCollections = PublishEngine.GetPublishInfo(childPage);
foreach (PublishInfo publishInfo in publishCollections)
{
if (publishInfo.PublicationTarget == engine.PublishingContext.PublicationTarget)
{
pageElem.SetAttribute("timestamp", publishInfo.PublishedAt.ToString());
}
}
}
//如果我们处于发布模式,请找出要发布到的目标,并获取页面发布到此目标的时间戳
if(engine.PublishingContext.PublicationTarget!=null)
{
ICollection publishCollections=PublishEngine.GetPublishInfo(childPage);
foreach(PublishInfo PublishInfo在publishCollections中)
{
if(publishInfo.PublicationTarget==engine.PublishingContext.PublicationTarget)
{
SetAttribute(“timestamp”,publishInfo.PublishedAt.ToString());
}
}
}
在这里,您可以看到我已经有了我的
childPage
对象,并且我正在将结果添加到现有的页面XML对象(pagelem.SetAttribute(“timestamp”,publishInfo.PublishedAt.ToString())
)-因此,如果使用此代码段,请注意以下项目:)您能解释一下何时尝试访问此信息吗?是在呈现页面或组件时,还是在发布之后的某个时间点?您还需要知道特定目标的此信息吗?