Why won’t this publication delete? – Published items

Within Tridion, should you need to delete a publication you need to ensure the following:

  • No pages in the publication are published
  • There are dependencies on the publication, child publications etc.

Normally it’s a simple case of un-publishing everything you need, removing these dependencies then away you go.

However in one particular instance when d

I wouldn’t be suprised if you’ve ever been in the situation where you wish to delete a publication but when trying to doing so Tridion throws up an error that the ‘publication contains published items’…

Luckily you can read more about the error by clicking the “details” button

Damn it, that isn’t useful.  What would be nice is if Tridion said “OK you’re an admin, shall I just get rid of it?” but unfortunately that isn’t the case.

So you’re in a situation, you want to remove the publication, but you’ve got published items and Tridion doesn’t have the functionality to tell you what is published.

To get round this problem I have written myself a little script that I run as a page template to give me a list of TCM id’s that are published.   It’s a simple piece of code but it’s incredibly helpful.  Here is how to use it:

  1. Create a new page template in your publication (or parent publication if one exists) called ‘Published pages list’ and enter the file extension txt.
  2. Copy the code below into this template.
  3. Save and close it.
  4. Once saved preview the code by chosing ‘Preview’ and selecting any page from the pop-up window.

The result should look a little like this depending on the number of published items you have:

What is great about the code is that it is simple enough to modify should you for example wish to see other information about the item for example if it is localised, checked out, get it’s  path, xml and so on.

The code

Function WhatIsPublished()

  dim lDomDoc, publicationURI, listColumnFilter, objListRowFilter, objTDSE
  dim pagenodes, objchild, mode, counter

  ' set basic variables
  counter = 0
  publicationURI = page.Publication.ID
  set objTDSE = CreateObject("TDS.TDSE")

  ' -- Column filtering
    listColumnFilter = 15 	' 15 contains IsPublished, IsShared, IsLocalized

  ' --- Row filtering
    set objListRowFilter = objTDSE.CreateListRowFilter()
    call objListRowFilter.SetCondition("ItemType", 68)	' 68 - page + sg
    call objListRowFilter.SetCondition("Recursive", true)
    call objListRowFilter.SetCondition("Recursive", true)

  XMLStr = Page.Publication.GetListItems(listColumnFilter , objListRowFilter)
  Set lDomDoc = GetNewDOMDocument()
  Call lDomDoc.loadXML(XMLStr)
  Set XMLRoot = lDomDoc.selectNodes("//tcm:ListItems")

  For Each Node In XMLRoot
    set pagenodes = Node.childnodes
      for each objchild in pagenodes
        if  objchild.getattribute("IsPublished") ="true" then
          Writeout objchild.getattribute("ID") & ""
        end if

  set objTDSE = nothing
  set XMLRoot = nothing
  set objListRowFilter = nothing

End Function

So now you’ve got a list of published item TCM id’s.  From here you can investigate the problem as to why they are published, reasons for which I will be covering in future posts.

So to recap.  Tridion will now allow the removal of a publication if it has published items, but the CMS doesn’t have a function to display a list of these items.  The script provided above allows you to create a simple list of items that are published, and from there you can investigate why and where these items are published.

3 thoughts on “Why won’t this publication delete? – Published items

  1. This is definitely a recognizable problem, and you have provided a helpful solution. Don’t forget by the way that there may also be components that are published dynamically. You would need to run a similar script to find those.
    And why not unpublish them from the page template while you’re at it?
    Set up an array with all the relevant publishing targets, and unpublish the pages and components once you have found them.

  2. Quirijn, thanks for the comments and feedback.

    Erwin – thanks, there are a variety of reasons why unpublishing the whole publication will not work. Here are a couple of examples (i’m sure there are many more!):

    1) There are X amount of published pages within a structure group. The structure group is modified so that it is no longer publishable. Unfortunately removing the right to publish also removes the right to unpublish.

    2) Pages are checked-out

    3) If the publication uses 2 different publication targets and all containing pages are published. Then the publication is modified to use only one publication target without the pages first being published.

    The idea of the code published is to give you an idea where these pages are located, then you can do you own analysis as to why they are not unpublishing. I’ve recently written a little bit of code to search structure groups and set their isPublishable value to true, i’ll post it later.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>