2

The binaries get published with TCM ID appended to their file name. I want to change the file name to be published without a TCM ID and path based on Structure Group.

The latest DD4T version has BinaryPathProvider which can be extended, but I am using an older version of DD4T (2.0.8) from DXA 1.6.

I have implemented a custom BinaryPublisher. How will this class be referred in DynamicComponentPresentation TBB which publishes the binary files?

1 - Implemented a custom Build Manager and in constructor we our referencing the custom Binary Publisher.

public CustomBuildManager(Package package, Engine engine) : base(package, engine)    
{     
    this.BuildProperties = new BuildProperties(package);   
    this.BinaryPublisher = new CustomBinaryPublisher(package, engine);    
}

2 - Created a custom Dynamic Component Presentation TBB which extends the BaseComponentTemplate class. In Transform method created a new instance of CustomBuildManager class.

public override void Transform(Engine engine, Package package)    
{    
    CustomBuildManager manager = new CustomBuildManager(package, engine);
    manager.SerializerService = this.Manager.SerializerService;
    this.Manager = manager;
    base.Transform(engine, package);    
}

But this customManager still references base Binary Publisher instead of custom class.

The only nuget package available is DD4T.Templates.Base which has base classes available. What package should I use for extending DynamicComponentPresentation class?

1 Answer 1

1
  1. Create a new Custom Build Manager extending default BuildManager (DD4T.Templates.Base.Builder).In this implementation, use your custom BinaryPublisher extendending default (DD4T.Templates.Base.Utils). In here, you can add or remove or override any additional methods from your base implementation as well (for your requirements)

  2. Create a new Custom DynamicComponentPresentation extending default (DD4T.Templates.DynamicComponentPresentation). You can replace the existing "Render Component Content" Core TBB to call your "Custom dynamic component presentation". In this implementation, override the GetDynamicComponent() and GetDynamicComponentPresentation() to use your custom build manager

I am using an older version of DXA but a newer version of DD4T. Let us know how it goes. Cheers!

Update

    /// <summary>
    /// In this method we call custom build manager to override default behaviour of PublishMultimedia
    /// </summary>
    /// <returns></returns>
    private Dynamic.Component GetDynamicComponent()
    {
        // Other code

        var customBuildManager = new CustomBuildManager(Package, Engine);
        Component tcmComponent = (Component)Engine.GetObject(item);

        // Calling the custom build manager object to override the default behaviour of PublishMultimedia
        Dynamic.Component component = customBuildManager.BuildComponent(tcmComponent);


    }

You also need to override GetDynamicComponentPresentation();

You will also need to extend the DXAStaticContextModule in the web application in order to be able to retrieve the binaries from different SGs and NOT from the default publication properties.

1
  • I have modified my question to add code reference. Can you suggest which package is available to use DynamicComponentPresentation class for extension? Commented Apr 5, 2018 at 7:07

Your Answer

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

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