9

While trying to figure out why components on one of our publications take longer to publish then on other publications we discovered an old component template that existed on just that publication. It looks like this CT was created as a learning/testing exercise in 2008 when we were first implementing Tridion and was not cleaned up before we launched our first Tridion site.

This component template publishes DCPs but we don’t actually use them for anything so we want to get rid of all of the DCPs and the template.

Because there are DCPs published using the template we cannot remove the linked schema associated with the CT nor can we change it from a DCP to a Static CP to disable future publishing.

What we’ve been thinking of is to first unpublish the CT which should remove all the DCP’s currently published using it and then deleting it. The potential issue here is there are 19,647 components using that CT so unpublishing will likely take so long to unpublish that in the meantime our editors will have published additional components which will trigger that DCP. This means we will have to go back to the start and unpublish the CT again and again until the count of published components using it is ‘0’.

I haven’t seen much (read: anything) about techniques for deleting CTs. Is this the only way to handle it or is there some other ‘best practice’ way to remove a CT that publishes DCPs?

6

Not sure if it's the shortest way, but how about:

  • Change template to be as harmless and as light as possible
  • Write custom resolver that will prevent components with this component template from being published (make sure to do it only on publish)
  • Unpublish and remove template

Of course you can stop at first step as it will already give you huge improvement

  • I would definitely not use a custom resolver for this while you could just as easily do it in the Event system. – Raimond Mar 9 '13 at 11:03
  • 1
    @Raimond: the choice of what gets published in response to a certain action sounds like a perfect use-case for a custom resolver to me. Would you mind explaining why you would prefer to do this in an event handler? – Frank van Puffelen Mar 9 '13 at 13:22
  • @FrankvanPuffelen Well, you could of course use a custom resolver so I shouldn't have said 'definitely', but to my mind, any resolver and the way it is placed in the Tridion architecture is meant for the processing of rendering/resolving content with a template in a certain way, which is defined in that resolver, whereas, as you say yourself, the response to an action should be altered, in which case it sounds more event like to me. I know this is splitting hairs. Additionally, using the event system has the benefit of letting it run only on Components and therefore limiting the trigger scope – Raimond Mar 9 '13 at 15:36
  • @Raimond In the event system, what would you subscribe to? ComponentPublish? And how are you going to stop item from being published in the event? Also, imagine you have page with 5 components, your event will be triggered 5 times, while using resolver you won't even get as far – Andrey Marchuk Mar 9 '13 at 19:19
  • Thanks. We did change the template to be as harmless as possible. Basically it doesn't really publish anything now. Onto the other parts of the work to remove the template... – Glenn Stevens Mar 11 '13 at 5:29
7

To prevent the ct from publishing while you are busy deleting it, the simplest approach is to make it fail. E.g. divide something by zero.

Also, the unpublishing may not take as long as you fear. Why don't you just try it? You need to do that anyway..

  • I should have mentioned it in my question but I had unpublished the template in our dev enviornment where the results (when multiplied by the # of components we have in production) were not very good in terms of the amount of time taken. Hence the reason for my question. – Glenn Stevens Mar 11 '13 at 5:32
6

There are multiple ways to do it, among which some hack work in the Tridion_cm database to set publish states, but let's go for the clean way:

  1. Prevent any Component / Component Template combination for that specific CT from publishing, as user978511 also mentions. I would do that by using the Event System. Presuming you use Tridion 2011, you could use a EventSystem.Subscribe(ComponentPublishPreventHandler, EventPhases.Initiated); method. In case of a pre-2011 system, OnComponentPublishPre would do the trick as well;

  2. Write a script or command line tool to unpublish those component presentations with priority Low. This would then not block content editors from publishing and because you have a separate script you could repeat the action across environments, or in case an error crops up during the unpublishing process. The preference would be to use Core Services for this, but the good old TOM API could be used for this as well.

  3. Once that's done, indeed remove all associations from that CT once everything is unpublished.

3

You could use the legacy TOM API to set the publish state of the Component Presenations using ComponentTemplate.SetPublishedTo to false for the targets and then remove it without actually unpublishing it from CD. PLease keep in mind this will keep the items published in CD database/filesystem where ever it was initially published.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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