6

I am trying to do implement a custom resolver for a component as described here by Chris: http://www.tridiondeveloper.com/the-story-of-sdl-tridion-2011-custom-resolver-and-the-allowwriteoperationsintemplates-attribute

I want to remove some of the binaries (mostly pdf's) used in component and prevent them from publishing. I am able to get the list of used items using item.GetListUsedItems method. How do I remove them?

using : tridion 2009

user1373140
  • 489
  • 2
  • 8
  • Could we interest you in committing to the [Area 51 Tridion specific proposal](http://area51.stackexchange.com/proposals/38335/tridion?referrer=gPujQMxthNCNn9xqeeO2NA2). Sign up with the same SO account if you have a moment. – Bart Koopman Aug 01 '12 at 08:00

2 Answers2

9

At Publishing time the resolver process determines which items should be published, like when you publish a Structure Group, the default Resolver will add all Pages in the Structure Group to the Publish Transaction.

Resolvers only deal with items in the Publish Transaction which are directly Publishable, and those are Pages and Dynamic Component Presentations. So a Resolver is not handling the linked Multimedia Components, those are Published by the Template code through calling the AddBinary() method.

If you want to remove Multimedia Components from your Publish action, you should look into the Component Template which is handling those (if they are added to the Package, the Default Finish Action TBB normally picks them up and Publishes them). But keep in mind, a Multimedia Component needs to be Published at least once else you will never get it on your presentation server.

Bart Koopman
  • 4,835
  • 17
  • 30
  • 1
    +1 for pointing out the difference, @Bart. Frank van Puffelen diagrams the two approaches (_implicit_ via template code/`AddBinary()` and _explicit_ via a multimedia publish and dynamic component templates) on [TridionWorld](http://www.sdltridionworld.com/community/2011_extensions/binaryeventtracker.aspx). – Alvin Reyes Aug 02 '12 at 00:42
3

Check the below code snippet to remove, you need to check whether the Multimedia is pdf or not but will get you going. Here is reference link very well explained with sample code as well (code below is from the same article).

http://www.tridiondeveloper.com/a-custom-resolver-in-practice

       Component component = (Component)item;
        if (component.ComponentType == ComponentType.Multimedia)
        {
            foreach (ResolvedItem resolvedItem in originalResolveItemList)
            {
                if (resolvedItem.Item.Id != item.Id)
                {
                    resolvedItems.Remove(resolvedItem); // to remove ..
                }
            }
        }
Ram G
  • 4,829
  • 1
  • 16
  • 26
  • I think the resolveditems list has components. I am trying to remove the binary item inside the component – user1373140 Jul 31 '12 at 14:04
  • How are you publishing the binary inside the Component? Is it via DWT code? If it is via DWT, then why do you want to remove the binary using the resolver since you will end up with broken binary link. If you are publishing the binary the above code will suffice your needs with check condition for `ComponentType.Multimedia` – Ram G Jul 31 '12 at 18:20