Click or drag to resize
AlchemyResource Groups

Resource Groups (hereforth called "groups" within the context of this page) are a collection of JavaScript files, Stylesheets, CommandSet references, and dependencies to other groups. Groups contain a unique name that identifies it from all other groups, whether they be from the core Tridion groups or groups within other extensions or plugins. Groups can be assigned to Extensions, so that when a specific extension is applied to a given page, Tridion ensures that the necessary references and dependencies are included for that page. Groups can also be used directly on Views.

Your plugin can contain 0 or more resource groups.

Adding Resource Groups

Traditional groups were added via the <cfg:group /> element within an editor configuration. In A4T, you'll add a class to your project that inherits from Alchemy4Tridion.Plugins.GUI.ConfigurationResourceGroup. If using the Alchemy4Tridion Developer Pack, you'll be able to select the Resource Group Item Template from the Add New Item menu in Visual Studio (it will be under "A4T/GUI").

using Alchemy4Tridion.Plugins.GUI.Configuration;
using Alchemy4Tridion.Plugins.GUI.Configuration.Elements;

namespace MyPlugin
{
public class MyResourceGroup : ResourceGroup
{
public MyResourceGroup()
{

}
}
}

Adding Files

JavaScript and Stylesheet files contained within your static folder can be added by their filenames directly (remember that even though you can organize your static files any way you chose, your JS and CSS will all end up in specific folders) using the AddFile(String) method.

C#
public MyResourceGroup()
{
    AddFile("MyCommand.js");
    AddFile("MyStyles.css");
}
Tip Tip

Order matters! If you have a file that depends on another one of your files, make sure to include that other one first!

Adding CommandSet References

Adding Dependencies

Dependencies are added to your group via the Dependencies property. The dependencies you add will vary on the requirements of your plugin. The Dependencies.AddAlchemyCore(); method will add the core script. If using some of the out of the box libraries that ships with Alchemy, you can use the Dependencies.AddLibrary...(); methods. Note that when using these extra libraries, they automatically include the core Alchemy script so there is no need to call AddAlchemyCore.

Adding the WebApi JavaScript Proxy

If your plugin uses web services via the ApiControllers, you can add an automatically generated JavaScript proxy to your group by calling the AddWebApiProxy method. This acts very similarly as adding AddFile(...) as it adds a file that points to the automatically generated file.

Tip Tip

Unlike normal AddFile calls, the AddWebApiProxy can be called anywhere within your constructor. The automatically generated JavaScript file will always be added as the first item in your group so that your other files can utilize it.

Unique Names

By default, A4T will use your plugin's name and the class' name to generate a unique identifier for the group. For example, if you plugin's name is MyPlugin and you create MyResourceGroup which inherits Alchemy4Tridion.Plugins.GUI.ConfigurationResourceGroup, the auto generated name for you group will be "Alchemy.Plugins.MyPlugin.Resources.MyResourceGroup".

Referencing Your Resource Groups

Your extensions (and groups) can reference your created groups via the generic AddT method. You can also use the fully qualified group name as the parameter, which is useful for when adding groups that are not built by you or are the core Tridion groups.

C#
Dependencies.Add<MyResourceGroup>();
Dependencies.Add("Alchemy.Plugins.MyPlugin.Resources.MyResourceGroup");
Dependencies.Add("Tridion.Web.UI.Editors.CME.commands");
See Also