What I learned from building my first Alchemy plugin

I finally found some time to start working on my own plugin built in this incredible new framework developed by Content Bloom called Alchemy. You can see my plugin on the Alchemy Webstore here. It’s called Not Used and it’s really just a basic cleanup tool that allows a Tridion user to search for and remove various items that are not in use. Perhaps more interesting than the plugin itself is the process of learning to work within the Alchemy framework, which requires a combination of knowledge in Tridion’s Anguilla framework, C# core service API and standard .NET web technologies. Some of these have documentation that is seemingly hidden or otherwise very difficult to track down and/or decipher. Here I discuss some of the trickier bits of my experiences developing an Alchemy plugin, in hopes that these details will help others encountering the same challenges. I’d like to give a special thanks to everyone who helped me along the way!

Anguilla:

There is a rough HTML version of the Anguilla API floating around, but what I found to be more effective is to look directly at the existing Tridion GUI code. You can access this code in your Tridion installation at C:\Program Files (x86)\Tridion\web\WebUI or another similar location. Once you locate the .js files there, you can use something like Notepad++ to search through the files to gain an understanding of how Anguilla JS code is written and find various pieces of code that you can tweak/reuse. In my case, I was looking to gain an understanding of how I can properly run the delete command in Anguilla. A quick search for delete gave me the following clues about what code I would need to delete a given unused item from Tridion:

anguilla_delete

InsertBefore:

The Alchemy documentation here shows how you can use the InsertBefore property when setting up a context menu in your Alchemy C# code to control where your menu item appears in the context menu. But other than cm_refresh, where else can you position a context menu item? Is there an exhaustive list of these constants somewhere to help you? In fact, yes, there is… sort of. Have a look in the following places:

  • Constants.cs
  • C:\Program Files (x86)\Tridion\web\WebUI\Editors\CME\Configuration\CME.config

Screen Shot 2016-01-09 at 6.09.35 PM

ItemType:

I originally limited my Not Used plugin to only support searching within folders. I achieved this with the following code:

if (items.length == 1 && (item.getItemType() == 'tcm:2'))...

Note tcm:2 is a folder in Tridion. But what if I wanted to extend my plugin to allow searching within categories/keywords, for instance, to find additional unused items? What is the item type for a category? In general, how do you find an item type? A nice quick reference suggested to me is to work in the browser’s developer console and use the following commands to display a list of item types:

var Tridion = frames[0];
Tridion.$const.ItemType

Screen Shot 2016-01-09 at 6.21.58 PM

You can quickly see that a category is tcm:512!

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>