Just wanted to check, is it a best practice to add items (
ResolvedItems list in a Custom Resolver? Or the Custom Resolver is to be used only for removing Resolved Items for the list?
If your question is how to publish additional items together with your item, then, just like everything else in Tridion, you have multiple options, where choosing one depends on your implementation, preferences, maintenance capability etc. So how you can achieve this:
- As you and Bart stated, yes, you can use a Custom Resolver to add items during publishing. This indeed will result in additional item being published withing the current transaction.
- You can create an Event System that will publish the additional item separately, so that way you will have 2 transactions in the Publishing Queue, which is OK if you want to have it more clearly stated to editors and publishing of both items together is not mandatory.
- there is also and option 3, where you can use the Publishing Engine to add items during publishing. Withing your Component/Page Template, you can add an additional
Dreamweaver template (DWT)which will execute
RenderComponentPresentation()over the additional item (if its a Component). Later on you can add your regular
DWTwhich will generate the
Output. SO what is the purpose of this and what you get? Basically, you achieve that your second Component is in the Package, so it will processed and published with the Template you have specified. You don't have to link it in your main Component, you can just have it read via Engine and pushed into Package and then rendered.
So whichever way you choose to go, please be aware that most problems/frustrations you can have in maintenance phase when after few months/years everyone forget what they were doing in implementation. As for me, I saw all 3 options implemented. :)
A Custom Resolver is for customizing the resolving, this includes adding and removing items indeed.
Personally I think it is more clear when you are adding items in a custom resolver, than removing them. But I have built both types of resolvers and if you make sure the customer understands that there is a custom resolver in play and what it does, it should never cause any unexpected issues.