We are using SDL Web 8.5 and DXA 2.0 Java. Our requirement is to publish an Excel file to a specific folder once a specific Component starts publishing. How can we achieve this using Event System?
Is the excel file managed in Tridion? If yes, then to have binaries deployed to a different folder than the default multimedia folder, you will need to use a method which takes a Structure Group as one of its parameters and the binary will end up in the corresponding file path.
If you can identify the specific component from within its template, then all you need to do is use the following method from within the CT, no need for an Event System:
The RenderedItem is available the following way
If you insist on an Event System, then from the top of my head, I would use the following approach.
- Have a dedicated CT which uses the previously described mechanism for publishing the binary. You can even have everything hardcoded.
- In a Publish Transaction Save event, check its state as
In Progressand whether the specific Component is being published. Do note that the challenge here is identifying whether that component is published indirectly, which can happen.
- After detecting that the specific component is being published, publish the dedicated CT from within the ES code, which will in turn publish your binary