Navigation

Documenting SDL Tridion Folders the Lazy Way

After several projects documenting SDL Tridion folder structures you'll realize they're stale and out-of-date faster than you can type them out. Resort to these alternatives, listed from mindless to-more-sophisticated brands of lazy.

1. Plain Lazy

If you have the folders in your software or desktop, choose from very lazy-to-almost passable:
  1. Print Screen
  2. Alt + Screen for just the window
  3. Cropped so it almost looks like text

2. Agile, Cheap, and Lazy

Create folders on desktop then use the CMD prompt to output the list.

dir /b/s > files.txt

Who knew joint application design sessions could be so easy? Btw, use the same command plus a diff tool to also troubleshoot dll lists. The /s gets subfolders and prepends the path, remove it to just get the first-level files.

3. Sophisticatedly Lazy

If this is for SDL Tridion 2011, open up Visual Studio or your IDE of choice, create a Core Service client and recurse away.

OrganizationalItemItemsFilterData orgItemfilter = new OrganizationalItemItemsFilterData();
orgItemfilter.ItemTypes = new[] {ItemType.Folder};
foreach (XElement element in core.GetListXml("tcm:5-5-2", orgItemfilter).Nodes())
{
    Console.WriteLine(element.Attribute("Title").Value);
    outputFolders(core, orgItemfilter, element, "");
}
//...
            
private static void outputFolders 
(ICoreService core, OrganizationalItemItemsFilterData orgItemfilter, XElement element, string indent)
{
    indent += "\t";
    XElement subElement = core.GetListXml(element.Attribute("ID").Value, orgItemfilter);
    foreach (XElement xElement in subElement.Nodes())
    {
        Console.WriteLine(indent + xElement.Attribute("Title").Value);
        outputFolders(core, orgItemfilter, xElement, indent);
    }
}

If grabbing attributes out of xElements pushes your lazy meter too far, instantiate a FolderData object and intellisense your way to each folder's Title, WebDavUrl, or Path.

var folderData = core.Read(xElement.Attribute("ID").Value, DEFAULT_READ_OPTIONS) as FolderData;
Console.WriteLine(indent + folderData.Title);Console.WriteLine(indent + folderData.LocationInfo.WebDavUrl);
Console.WriteLine(indent + folderData.LocationInfo.Path);

Creative laziness for the win. May your future folder documentation be as simple as 1-2-3.
If the simple Core Service example gets you thinking about others ways to auto-document your implementations, consider joining the PowerTools group. It's fairly trivial to output all kinds of lists with the Core Service--wouldn't it be nice to push a button to get things like schema documentation.
Wait, you haven't seen that extension? Come on, don't be that lazy.

No comments:

Post a Comment

Feel free to share your thoughts below.

Some HTML allowed including links such as: <a href="link">link text</a>.