2

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

  • Can you clarify where? Is this on CM side or Deployer side? – Nuno Linhares Dec 10 '15 at 11:19
  • Can you provide more details around your requirement. Why you want to check if a page is published for first time or it is republishing.. – Mukesh Kumar Dec 10 '15 at 11:35
  • It's possible from a template to test whether a page is currently published, but if it's been published and then unpublished again, that would be much harder. Which of these do you need? It would help if you can explain why? – Dominic Cronin Dec 10 '15 at 15:02
  • This might be okay for some technical integrations, but I've suggested to use the published date sparingly in this post. If that date is related to your content's "published date," you'll run into problems especially when moving things between CMS development environments. – Alvin Reyes Dec 10 '15 at 18:36
3

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

|improve this answer|||||
2

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:

|improve this answer|||||
2

There are three extension points you have accessible (for writing to content) when publishing.

  1. Event System - use the OnPublishPre event and update content. This is after the rendering phase, but before resolving.
  2. Custom Resolver - Add or remove items to the resolved content. For example, Component Presentations.
  3. Custom Deployer - Get the package of published content and add, update or remove metadata or other content in the Deployer phase.

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.