سؤال

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

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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 ..
                }
            }
        }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top