Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the (un-) PublicationTarget for component UnPublish event in Tridion 2011?
    primarykey
    data
    text
    <p>I'm using Tridion 2011's Event System to perform some additional actions when un-publishing components. I'm using code found <a href="http://yatb.mitza.net/2012/04/how-to-publish-stuff-programmatically.html">here</a> to publish a related component.</p> <p>I'm registering my event handler as follows:</p> <pre><code>EventSystem.Subscribe&lt;Component, UnPublishEventArgs&gt;( RemoveAndRepublish, EventPhases.Initiated); </code></pre> <p>... and my handler method is as follows:</p> <pre><code>public void RemoveAndRepublish(Component cmp, UnPublishEventArgs args, EventPhases phase) { // ... code to locate related component, and perform required actions... var instruction = new PublishInstruction(cmp.Session) { DeployAt = DateTime.Now, RenderInstruction = new RenderInstruction(cmp.Session) { RenderMode = RenderMode.Publish }, ResolveInstruction = new ResolveInstruction(cmp.Session) { IncludeComponentLinks = true }, RollbackOnFailure = true, StartAt = DateTime.MinValue }; var target = args.Targets.FirstOrDefault(); PublishEngine.Publish(new[] {related}, instruction, new[] {target}); } </code></pre> <p>My problem is that the <code>UnPublishEventArgs.Targets</code> property is an <code>IList&lt;PublishingTarget&gt;</code>, which at runtime turns out to be a <code>List&lt;TargetType&gt;</code>, and I need to get a <code>PublicationTarget</code> object to be able to call <code>PublishEngine.Publish(...)</code>.</p> <p>My question is: is there a way to get the current (un-)PublicationTarget from an UnPublish event?</p> <p>Can anyone offer any help?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload