TOM.NET APIを使用して、特定のページまたはコンポーネントの公開されたタイムスタンプを特定のターゲットに取得しようとしています。Page
またはComponent
オブジェクトの下ですぐにはわかりませんが、誰かが私を正しい方向に向けることができますか?
2 に答える
7
そのためのメソッドを使用できます。このメソッドは、指定されたアイテムで使用可能な日付およびその他の(公開)情報を保持するオブジェクトPublishEngine.GetPublishInfo(IdentifiableObject)
のコレクションを返します。PublishInfo
于 2012-04-10T16:12:25.263 に答える
2
上記のBartの回答のおかげで、次の大まかなコードをノックアップしました。これは、顧客に何かをデモするための概念実証であるため、パフォーマンスではありません。
// 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());
}
}
}
ここで、私はすでにchildPage
オブジェクトを持っており、結果を既存のページXMLオブジェクトに追加していることがわかります(pageElem.SetAttribute("timestamp", publishInfo.PublishedAt.ToString())
)-したがって、このスニペットを使用する場合は、これらのアイテムに注意してください:)
于 2012-04-10T16:47:59.120 に答える