1

I am migrating my code of Event Code system from Tridion 2009 to Tridion 2011(SDL TOM.NET), I am facing some problem while publishing page via code. My existing code which is written in Tridion 2009 is as below.

PublicationTarget targets = null;
TDSEClass class2 = new TDSEClass();
targets = class2.GetPublicationTarget(pubTargUri);
page2.Publish(targets, false, true, true, DateTime.Now.AddMinutes(-82.0), DateTime.MinValue, DateTime.Now, true, EnumPublishPriority.Normal, false, 0);

But I do not have any idea to do same thing in 2011. I had also tried to get help from the document but did not success.

Thanks.

1
  • check the item types of the new arguments. For example, targets is an array of string URIs. Also, please post your solution code here when it is working to help devs in future. Thanks.
    – robrtc
    Mar 11, 2014 at 9:56

3 Answers 3

3

Like I told you in my previous answer and comment on your question, check out the sample code of my Rapid Editorial Interface event handler, that shows you how to Publish items using the TOM.NET API in lines 75 to 132 of RapidEditorialInterface.cs.

It basically comes down to:

// adding current item to the list of items to publish
List<IdentifiableObject> items = new List<IdentifiableObject>();
items.Add(subject);

// publish item(s)
List<TargetType> targets = new List<TargetType> { new TargetType(myTargetTypeUri, subject.Session) };
PublishInstruction publishInstruction = new PublishInstruction(subject.Session);
PublishEngine.Publish(items, publishInstruction, targets, PublishPriority.Normal);
2
  • this works for page, as i get the myTargetTypeURI from the page stuff, but when there is no publishing of the component, say event code on component save and close. In such a scenario how can i get the myTargetTypeURI
    – Urvesh
    Mar 19, 2014 at 10:54
  • 1
    @Urvesh You have to configure it somewhere, see how I do this in my Rapid Editorial Interface (I'll keep repeating that same answer till you actually take a look at it ;o). Mar 19, 2014 at 11:08
2

Look up Tridion.ContentManager.Publishing.PublishEngine.Publish()

2

Pages, Components etc. no longer have Publish methods. Instead, you can use the static class Tridion.ContentManager.Publishing.PublishEngine and call it's Publish method, specifying any Identifiable Objects and Publication Targets or Target Types to publish to.

Download the TOM.Net programmers reference guide from the API documentation (login required) and look up the Publish method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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