My first Alchemy Plugin

abort-publishing-iconSo I wanted to make a really simple Alchemy plugin to test out the amazing new SDL Web plugin store that my colleagues have been working on this year.  It’s a simple plugin where I inject a little bit of javascript into the publish dialog to permanently check the ‘Abort Publishing’ check-box button, but it’s a great learning experiment plus its a nice example if you’re looking to write a plugin that simply adds a bit of javascript or css etc.

sdl-web-plugin-abort-publishingSo here’s what I did!

First I set up a project based on the hello world project and removed a tonne of stuff that I didn’t need like the controllers and the web service stuff.

I then created the items you see in the screen shot :

 

Because we don’t have any menu or ribbon items, it’s a really simple extension, here’s how it works:

In my PublishDialogExtensionGroup.cs file, I essentially said “I’d like to inject my AbortPublishingResourceGroup into the Tridion Publish Popup, here’s the code:

    class PublishDialogExtensionGroup : ExtensionGroup    {
        public PublishDialogExtensionGroup()        {
            AddExtension("Tridion.Web.UI.Editors.CME.Views.Popups.Publish");
        }
    }

My AbortPublishingResourceGroup.cs file contains a reference to my javascript like this:

    public class AbortPublishingResourceGroup : ResourceGroup
    {
        public AbortPublishingResourceGroup() : 
            base("CommandFiles")
            {
                AddFile("AbortPublishing.js");
            }
     }

My AbortPublishingCommandSet.cs file is essentially an empty class.

In my Javascript i’ve the following code:

$evt.addEventHandler($display, "start", onDisplayStarted);

function onDisplayStarted() {
    if ($("#abortOnError").length != 0) { 
        $("#abortOnError").checked = true;
        $("#abortOnError").disabled = true;   
    }
    else {
        $log.message("Content Bloom Alchemy Plugin / AbortPublishingDefault : Could not find 'Abort on Error' checkbox");
    }
}

 And that’s it!  It took me longer to write this blog post than to make it, so i’m pretty damn stoked on Alchemy.

If you’d like to use the plug in, search for ‘Abort Publishing’ over on Alchemy, it looks like this:

abort-publishing-screenshot

If you’d like the .net project to check it out, here’s the file.  Happy coding.

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>