Skip to main content
deleted 27 characters in body; edited tags; edited title
Source Link
Bart Koopman
  • 29.6k
  • 3
  • 40
  • 90

Publish multimedia componentComponent to server with AddBinary method

i'mI'm trying to publish multimedia content (images) on my server from a C# Template building blockBuilding Block.

I tried the following  :

uri2 is the tcmUri of a folder where i want the image to be published on the server and component is the component containing the image.

// Get the component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// Get the fields
ItemFields fields = new ItemFields(c.Content, c.Schema);
// get our Embedded schema field
EmbeddedSchemaField emb = (EmbeddedSchemaField)fields["Slide"];
// Loop
foreach (ItemFields embeddedfields in emb.Values)
{
    foreach (ItemField field in embeddedfields)
    {
        ComponentLinkField fieldImage = field as ComponentLinkField;

if (fieldImage !=null){
            Component component = fieldImage .Value;
            string componentId= component.Id;
            package.PushItem("ARN", package.CreateStringItem(ContentType.Text, componentId));
             
             TcmUri uri2 = new TcmUri("tcm:126-3103-4");
             StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
           string replace = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;
        }
    }
}

uri2 is the TCMUri of a Folder where I want the image to be published on the server and component is the Component containing the image.

With that code, iI get the following error using template builderTemplate Builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

Thanks for your help and advices

Publish multimedia component to server with AddBinary method

i'm trying to publish multimedia content (images) on my server from a C# Template building block.

I tried the following  :

uri2 is the tcmUri of a folder where i want the image to be published on the server and component is the component containing the image.

// Get the component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// Get the fields
ItemFields fields = new ItemFields(c.Content, c.Schema);
// get our Embedded schema field
EmbeddedSchemaField emb = (EmbeddedSchemaField)fields["Slide"];
// Loop
foreach (ItemFields embeddedfields in emb.Values)
{
    foreach (ItemField field in embeddedfields)
    {
        ComponentLinkField fieldImage = field as ComponentLinkField;

if (fieldImage !=null){
            Component component = fieldImage .Value;
            string componentId= component.Id;
            package.PushItem("ARN", package.CreateStringItem(ContentType.Text, componentId));
             
             TcmUri uri2 = new TcmUri("tcm:126-3103-4");
             StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
           string replace = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;
        }
    }
}

With that code, i get the following error using template builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

Thanks for your help and advices

Publish multimedia Component to server with AddBinary method

I'm trying to publish multimedia content (images) on my server from a C# Template Building Block.

I tried the following:

// Get the component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// Get the fields
ItemFields fields = new ItemFields(c.Content, c.Schema);
// get our Embedded schema field
EmbeddedSchemaField emb = (EmbeddedSchemaField)fields["Slide"];
// Loop
foreach (ItemFields embeddedfields in emb.Values)
{
    foreach (ItemField field in embeddedfields)
    {
        ComponentLinkField fieldImage = field as ComponentLinkField;

if (fieldImage !=null){
            Component component = fieldImage .Value;
            string componentId= component.Id;
            package.PushItem("ARN", package.CreateStringItem(ContentType.Text, componentId));
             
             TcmUri uri2 = new TcmUri("tcm:126-3103-4");
             StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
           string replace = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;
        }
    }
}

uri2 is the TCMUri of a Folder where I want the image to be published on the server and component is the Component containing the image.

With that code, I get the following error using Template Builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

added 857 characters in body
Source Link
user1178
user1178

i'm trying to publish multimedia content (images) on my server from a C# Template building block.

I tried the following :

uri2 is the tcmUri of a folder where i want the image to be published on the server and component is the component containing the image.

// Get the component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// Get the fields
ItemFields fields = new ItemFields(c.Content, c.Schema);
// get our Embedded schema field
EmbeddedSchemaField emb = (EmbeddedSchemaField)fields["Slide"];
// Loop
foreach (ItemFields embeddedfields in emb.Values)
{
    foreach (ItemField field in embeddedfields)
    {
        ComponentLinkField fieldImage = field as ComponentLinkField;

if (fieldImage !=null){
            Component component = fieldImage .Value;
            string componentId= component.Id;
            package.PushItem("ARN", package.CreateStringItem(ContentType.Text, componentId));
             
             TcmUri uri2 = new TcmUri("tcm:123126-37443103-2"4");
             StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
           string valreplace = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;
        }
    }
}

With that code, i get the following error using template builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

Thanks for your help and advices

i'm trying to publish multimedia content (images) on my server from a C# Template building block.

I tried the following :

uri2 is the tcmUri of a folder where i want the image to be published on the server and component is the component containing the image.

TcmUri uri2 = new TcmUri("tcm:123-3744-2");
StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
string val = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;

With that code, i get the following error using template builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

Thanks for your help and advices

i'm trying to publish multimedia content (images) on my server from a C# Template building block.

I tried the following :

uri2 is the tcmUri of a folder where i want the image to be published on the server and component is the component containing the image.

// Get the component
Component c = (Component)engine.GetObject(package.GetByName(Package.ComponentName));
// Get the fields
ItemFields fields = new ItemFields(c.Content, c.Schema);
// get our Embedded schema field
EmbeddedSchemaField emb = (EmbeddedSchemaField)fields["Slide"];
// Loop
foreach (ItemFields embeddedfields in emb.Values)
{
    foreach (ItemField field in embeddedfields)
    {
        ComponentLinkField fieldImage = field as ComponentLinkField;

if (fieldImage !=null){
            Component component = fieldImage .Value;
            string componentId= component.Id;
            package.PushItem("ARN", package.CreateStringItem(ContentType.Text, componentId));
             
             TcmUri uri2 = new TcmUri("tcm:126-3103-4");
             StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
           string replace = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;
        }
    }
}

With that code, i get the following error using template builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

Thanks for your help and advices

Source Link
user1178
user1178

Publish multimedia component to server with AddBinary method

i'm trying to publish multimedia content (images) on my server from a C# Template building block.

I tried the following :

uri2 is the tcmUri of a folder where i want the image to be published on the server and component is the component containing the image.

TcmUri uri2 = new TcmUri("tcm:123-3744-2");
StructureGroup sg = new StructureGroup(engine.GetSession(),uri2);
string val = engine.PublishingContext.RenderedItem.AddBinary(component, sg).Url;

With that code, i get the following error using template builder:

Invalid context Publication specified in URI: New StructureGroup (parent: tcm:123-3744-2). Expecting: 123.

Thanks for your help and advices