I need to know if the page is published for the first time in Tridion?
I need to pass some parameters when page is published for the first time.and different set of parameters when page is republished
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI need to know if the page is published for the first time in Tridion?
I need to pass some parameters when page is published for the first time.and different set of parameters when page is republished
If you are using TOM.NET there is IsPublished method in PublishEngine class:
using Tridion.ContentManager.Publishing;
...
if (PublishEngine.IsPublished(page))
{
// Some logic
}
For more info about the page publishing you can use:
foreach (PublishInfo info in PublishEngine.GetPublishInfo(page))
{
info.PublicationTarget.Title; // Which publication target
info.PublishedBy.Title; // Who published it
info.PublishedAt; // Gets the DateTime at which the item was last published.
}
Something similar was answered in post: How do I determine if a Component is Published based on the current TargetType
If you are using Core Service use IsPublished method of Core Service client:
string pageId = "tcm:10-259165";
if (client.IsPublished(pageId, "tcm:0-0-0", true))
{
// Some logic
}
For more info about the page publishing you can use:
string pageId = "tcm:10-259165";
foreach (var info in client.GetListPublishInfo(pageId))
{
info.PublicationTarget.Title; // Which publication target
info.Repository.Title; // Which publication
info.PublishedAt.ToShortDateString(); // Gets the date/time at which the item was last published.
}
Something similar was answered in post: How to identify if a Component is published or not in a child Publication using the Core Service
If you want to do it from a CM side, you could check the last published date of the page, if it is null/empty then it is never published, in other words, it is being published for the first time.
You might want to look at this post to retrieve the last published date of the page:
There are three extension points you have accessible (for writing to content) when publishing.
Unfortunately, with Compound Templating and TOM.NET you cannot modify content at publish time as it was possible in version 5.x and VBScript templating.