Although the contained components are ported from DEV to UAT to PROD, adding the components to the containers is done manually. This usually works well, but what happens when some links are missing? How do you sort through hundreds of component links to find if you need to add one?
In this post I show how to use Excel and Notepad++ to work with the contents of the container component.
The component that we are working with looks like the image below.
This shows six out of about 250 linked components, which are not in any order. Sorting through this component manually, to see if we need to add another component link, will take a long time indeed. There is a faster way, but we have to be mindful of the schema.
The schema for this is very simple. It is a single repeatable field. This technique will not work if there are multiple fields.
To sort the component links within this very simple container:
1) View the Source tab of the container
2) Copy the entire contents to Notepad++
3) In this case we want to sort the file by the xlink:title property. Press Ctrl-H to open Search & Replace; replace xlink:title with \t\txklink:title. Be sure that the “Extended” search mode is used so that “\t” is seen as a tab character.
4) Copy All, and paste into a blank spreadsheet in Excel. The columns break on the \t characters. The first column (not indented) is in column A. The second is in column B. The first tab means that column C is empty. The xlink:title, and everything past that, is in column D.
Note that cell D2 contains the xlink:title value. We are now able to sort by this column.
5) Select the range that includes columns B through D, but excludes the top & bottom row, and sort the range by column D.
Note that column D is now ordered alphabetically.
6) Copy all of the rows, including the top and bottom row, and paste back in to Notepad++
7) replace \t\txlink:title with xlink:title to remove the two tab characters.
8) Copy All & paste in to the Source tab in Tridion.
9) Save and check in the updated component.
And there you have it — We have used Excel and Notepad++ to quickly, easily, and safely, sort all of the component links in a container.
We can now scan through the list of components, alphabetically, and identify any that are duplicated or are missing.
This isn’t something that you will do every day, but when you need to do it then it can really help.