-6

Is it possible to publish a Page by using Tom.net API in SDL Tridion 2011?

user1573378
  • 145
  • 1
  • 7

2 Answers2

2

As Nuno mentioned, use PublishEngine.Publish and refer the syntax and example

Syntax:

PublishEngine.Publish(
    new IdentifiableObject[] { linkedComponent },
    engine.PublishingContext.PublishInstruction,
    new List() { engine.PublishingContext.PublicationTarget }); 

Do something like this:-

private void Publish(IdentifiableObject item, PublicationTarget publicationTarget, bool rollBackOnFailure, bool includeComponentLinks)
{
    IEnumerable<IdentifiableObject> items = new List<IdentifiableObject>() { item };    
    IEnumerable<PublicationTarget> targets = new List<PublicationTarget>() { publicationTarget };
    PublishInstruction instruction = new PublishInstruction(item.Session)
    {
        DeployAt = DateTime.Now,
        RenderInstruction = new RenderInstruction(item.Session)
        {
            RenderMode = RenderMode.Publish
        },
        ResolveInstruction = new ResolveInstruction(item.Session)
        {
            IncludeComponentLinks = includeComponentLinks
        },
        RollbackOnFailure = rollBackOnFailure,
        StartAt = DateTime.MinValue
    };
    PublishEngine.Publish(items, instruction, targets);
}

**Contents is copied from How to Publish Stuff Programmatically blog

Siva Charan
  • 17,940
  • 9
  • 60
  • 95
1

Use PublishEngine.Publish, follow Intellisense from there. You'll need to provide Render and Resolve instructions, as well as the usual details like Target, start date/time, etc.

The documentation has samples, various blogs have samples, and Visual Studio should help you find what you need.

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
  • 1
    Sorry if I'm being rough, but this is a really simple task. Lesson #1: Tridion Content Manager Explorer uses the same API that you do, if it can do something, then you can do it too. – Nuno Linhares Dec 04 '12 at 14:35