-1

We need to determine who triggered the publishing of a Tridion 2009 page: editor or code.

Please use as an example: Publication A Publication B which inherits from A

Now when we publish a page in publication A using “Also publish/unpublish in Child Publications” the event system will be triggered for the page in publication A and also for the page in publication B.

In this case we want to use the event system only on the page from publication A

Something like:

public override void OnPageSetPublishedToPost(Page page, string publicationTarget, bool published, string user)
{
  if (!page.IsTriggeredByParent)
  {
  // do stuff
  }
}

The problem is we don`t know how to determine the value for “IsTriggeredByParent”.

Thank you for your time

tacanitii
  • 1
  • 2
  • Can yo specify which version of Tridion you are working on, and which event handler/trigger you are trying to use. – Chris Summers Mar 20 '12 at 10:19
  • We are using Tridion 2009. The event is: `public override void OnPageSetPublishedToPost(Page page, string publicationTarget, bool published, string user)` called after a page is published. Inside we need to determine if the publish act is triggered by a parent publication. – tacanitii Mar 20 '12 at 10:38
  • Without a lot of digging, I am not convinced what you are trying to do is possible only using the OnPageSetPublishedToPost trigger. Is there any way you can use the OnPageResolvePre event? Perhaps you can explain what you are actually trying to achieve in your code so that we can propose another creative solution. – Chris Summers Mar 20 '12 at 10:52
  • I think that to solve this problem, you are going to have to tell us more about it. You have settled on a technique using OnPageSetPublishedToPost, but are only giving veiled hints about the problem domain. So why do you want to treat these two scenarios differently, and what does "do stuff" mean. Maybe by taking a broader view we can help better. – Dominic Cronin Mar 28 '12 at 18:36

1 Answers1

4

In SDL Tridion 2009 this is impossible, the COM Based event system there has no way of identifying where an event came from.

In the SDL Tridion 2011 .NET event system, you have access to the event stack. This means you can detect if an action is performed as part of another action (for example, a Save on a VersionedItem with the parameter true will also Check-In the item and raise that event as part of the Save event). So to accomplish your task I think you require an upgrade.

Bart Koopman
  • 4,835
  • 17
  • 30
  • Thank you Bart. This at least clarifies the issue. There is no direct solution for 2009. We are trying a different approach. Inside the publish event we want to queue the parent page and when child pages of the queued one arrive we can choose to ignore the event. The solution clearly assumes that when publishing pages Tridion (with asyncevents set to false) first calls the event for parent page 1, then its child pages and then it passes to parent page 2. Do you think that could work ? – tacanitii Mar 20 '12 at 14:42
  • If memory serves me correct, the COM based event system, will not trigger events based on other events. So not sure if what you are stating is going to work. If you are programatically adding the parent in the publish queue, that will be handled as a different publish transaction and it will have its own event. – Bart Koopman Mar 20 '12 at 14:53
  • The events are already working. Basically OnPageSetPublishedToPre now gets called for page A and then for each child page of A. This is actually the problem. We plan to queue certain calls(for parent pages) inside OnPageSetPublishedToPre and skip the standard code of the method for child pages that are processed immediately after the parent. For this to work we need Tridion to always call the events in a clear way: parent A, childre A1, children A2, parent B ... – tacanitii Mar 20 '12 at 14:57
  • That should happen, when you queue publish actions from event they will be triggered after it, but the actual order is still depending on the actual order of processing the publish transactions. If you have a single publisher thread is exactly as what you see in the queue, if you have multiple threads the order of OnPageSetPublishedToPre can be different related to which threads gets committed first. – Bart Koopman Mar 22 '12 at 09:59
  • I still think you will have better options in SDL Tridion 2011 because then the event system will be able to tell you more and you can set a context variable in the event args which is passed along to the other events triggered by that item. – Bart Koopman Mar 22 '12 at 10:04
  • The COM events system *does* trigger events based on other events, as you'll know if you've ever had to untangle an OnComponentSavePost that saves the component! Similarly, workflow events would also fire if appropriate. – Dominic Cronin Mar 28 '12 at 18:32
  • true, but till a certain extent. I can't remember the exact details when it would and where it would stop, just know its not something you want to depend on. – Bart Koopman Mar 28 '12 at 21:15