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:
- Create a new page template in your publication (or parent publication if one exists) called ‘Published pages list’ and enter the file extension txt.
- Copy the code below into this template.
- Save and close it.
- 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
next
Next
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.