This year the SDL Web Dev Summit India was hosted in Delhi and I had the opportunity to present about the Tridion Alchemy Framework. For the presentation I ported to Alchemy an older custom ASP script to delete (and unlocalize) All Blueprint Children. In this article I will highlight the process I used and include a link to the sourcecode. I stil need to polish a few things before I add it to the Alchemy store, but please have a look at my code and hopefully it will help you in building your Alchemy plugins.
Here I will outline the steps I followed to write the plugin. I won’t dive into too much detail, but I hope this will help you get started.
Writing a plugin involves looking at some good code samples. So, my first step was to download and install every Alchemy plugin and also every sourcecode repository that was available.
The latest version of the Alchemy VSIX Visual Studio Plugin has a nice Project Type called ‘Starter Plugin Project’. This creates a nice example with a button in the ribbon and also context menu. In my presentation I was able to go from File, New Project to having an Alchemy Plugin in my Tridion system in under 3 minutes. The reason I like the starter project so much (aside form the fact it’s very easy and fast to use) is it has a great clean structure of the files and folders, and provides an excellent reference.
Writing the GUI
The GUI is now much easier to write and install than ever before (especially if you’ve done GUI Extensions!). However, there is some rhyme and reason for a lot of the things in the Alchemy framework and I will try to highlight a few here.
1. Create the Static folder. This holds your Commands .js file (which is executed when you fire the GUI event, and the same one we used in older GUI Extensions). Also in static you’ll have any .aspx popup files and css/js files your popup uses. In Static I create a Commands folder.
3. In the .js file, I define a command name, ‘UnLocalizeAllCommand’ that is very important and will be used later. I also borrowed some code from Mark Richardson’s ‘Real Time Publishing Stats’ plugin to open the popup .aspx file. *Note – in this version your popup must be an .aspx file and not .html. Otherwise, it will not be deployed to the views folder when you deploy the .a4t file.
5. Next is to Add the button to the GUI. The context menu is added with ContextMenuUnlocalizeAll.cs and Ribbon is from RibbonToolbar.cs.
6. Next we tell Alchemy what files to include for us with the ResourceGroupFiles.cs and PopupResourceGroup.cs files.
7. With the PluginCommandSet.cs we specify the same command name we used in step 3.
8. Now we could build and deploy the Alchemy Plugin and we should be able to see the items in the context menu and ribbon bar. The last step is to add the functionality to do something.
9. Create the controller, UnLocalizeController.cs, in a new Controllers folder and make sure to reference the Core Service Client. Here is where the main functionality is impemented. Carefully look at the AlchemyRootPrefix attribute and also the Route attribute on the class. These 2 parameters define how we access the service.
10. Finally, build the project to create the .A4T file. If you get annoyed with the alchemy popup window, disable it by opening your .csproj file (in Notepad++ you’ll need to run it with the Admin user) and follow my tip here to disable it for Dev.
Full Source Code is available here: https://github.com/rcurlette/AlchemyUnlocalizeAllChildren/
I hope this article helped you understand the flow of building an Alchemy plugin and assists you in your plugin dev. Please share your plugins on the Alchemy WebStore so we can all benefit from the community. Special thanks to Pankaj Guar for inviting me to speak at the SDL Web Developer Summit India! Big thanks to Content Bloom and Alex Klock for creating the Alchemy Framework and sharing with the world!
Leave a Reply