Using Custom Settings within your Alchemy 4 Tridion GUI Extension

alchemyI’m in the process of creating my first Alchemy Extension that uses custom configuration settings and I thought I’d share some learning as I go as I think it’s safe to say a good chunk of all extensions will use some sort of custom configuration.

So the first place to start is the API docs, there’s a great post here about getting started here.

So in my plugin’s A4T.xml file I had (at first) the following XML:

 <settings>
 <Category>874</Category>
 <PubId>42</PubId>
 </settings>

All good so far (hint, for what I’m doing this isn’t quite right, but we’ll get to that).

So i’m using JavaScript to access these settings in my extension interface, i’m using the following code:

Alchemy.Plugins["${PluginName}"].Api.getSettings()
.success(function (settings) {
    $messages.registerGoal("Settings are: " + JSON.stringify(settings));
})
.error(function () {
    $messages.registerError("There was an error", error.message);
})
.complete(function () {
    progress.finish();
});

Which is actually all good code, but when I came to test the result, I saw that no data is coming back.

Thankfully I can ask Alex Klock what i’m doing wrong (and most likely you can too, he’s insanely helpful), and he informed me that I need to wrap the XML nodes that I’d like either like this:

 <settings>
    <Category client="true">874</Category>
    <PubId client="true">42</PubId>
 </settings>

Or like this:

 <settings>
   <client>
    <Category>874</Category>
    <PubId>42</PubId>
   </client>
 </settings>

So you may see now where I went wrong?  – that’s right, I’d not told the XML that certain configuration nodes are available to the client by adding either the <client> node, or the client=”true” attribute.

This is actually documented in the Alchemy API docs, but if I missed them, perhaps you will too.

And if you’ve not read those docs, but you read this blog, you may not even realise that it’s possible to add these configuration settings to your Alchemy extensions.

This entry was posted in A4T and tagged , by John Winter. Bookmark the permalink.

About John Winter

Over the last 15 years, John has lead over 50 SDL Tridion implementations for major clients including, Alliance Data, Viking Cruises, Lexus, Dunlop, Dexia Bank, Toyota and SKF. John manages the USA side of Content Bloom, undertaking a variety of tasks including consultancy, development, architecture and trainer.

One thought on “Using Custom Settings within your Alchemy 4 Tridion GUI Extension

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>