Tridion provides great Blueprint functionality allowing us to share and localize content across many locales and Publications. Sometimes we want to make a copy of an item – the whole item with all of its’ Blueprint-children, and then maybe change some metadata with the new item and nothing else. However, the copy button in Tridion only copies the current item – and not its’ associated Blueprint-children.
Tridion BCopy – When A copy is not enough
Tridion BCopy copies the item (Component, Page, Structure Group, or Folder) and all of its’ Blueprint-children, including associated metadata, etc. When copying a Folder or Structure Group it does not copy the contents of it – only the item itself.
The code is written in classic ASP – yes, I hear you moaning or cheering, but rest assured this approach works on all versions of Tridion up to Tridion 2011 and is quick to deploy and start using right away. I tested the code on Tridion version 5.3 and it works great.
Getting Localized Items
The most interesting part of the code is getting the localized items. This approach uses the GetListUsingItems and a special RowFilter condition. You might want to use the same code to process localized items for updates, etc, and I have used it many times.
Function GetLocalizedItemNodes(itemUri) Dim tridionItem : set tridionItem = tdse.GetObject(itemUri,1) Dim rowFilter : set rowFilter = tdse.CreateListRowFilter() call rowFilter.SetCondition("ItemType", GetItemType(itemUri)) call rowFilter.SetCondition("InclLocalCopies", true) Dim usingItemsXml : usingItemsXml = tridionItem.Info.GetListUsingItems(1919, rowFilter) Dim domDoc : set domDoc = GetNewDOMDocument() domDoc.LoadXml(usingItemsXml) Dim nodeList : set nodeList = domDoc.SelectNodes("/tcm:ListUsingItems/tcm:Item[@CommentToken='LocalCopy']") set tridionItem = nothing set domDoc = nothing set GetLocalizedItemNodes = nodeList End Function
We use the GetXML method to get the contents of the item.
GetLocalizedXml = localizedItem.GetXml(1919)
When updating, we use the UpdateXml method of an item to save the original contents to the copy. This is the best and fastest way to update Tridion content.
I use Twitter Bootstrap version 1.0 for all custom pages. If you have not checked this out – you need to. No need to write your own CSS for custom pages anymore! Use the Bootstrap HTML / CSS and have nice looking custom pages in no time.
Upload to server
Copy to the Tridion/Web/CustomPages folder on your server or wherever you put your asp custom pages.
Create a link to it in the Custom Pages tree menu and save time with it!