Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing "customconfiguration" inside GUI Extension

I'm doing a GUI Extension of User Interface (SiteEdit) by overriding the behaviour of one of the javascript files, to add some funcionality. The javascript file is "/Scripts/Components/ExtComponentField.js" and the target is "SiteEdit" extending:

Tridion.Web.UI.Editors.SiteEdit.Views.Content

All works well with the extension, and I have what I wanted to have, but now I'm trying to use the

settings/customconfiguration/clientconfiguration

node of the extension config, to use some initialization parameters, but there is no way to access $config element in the javascript, and Tridion.Core.Configuration.Editors["myExt"].configuration is null.

I've seen using this customconfiguration in various javascripts like "Dashboard" or "Footprints", but is it possible to have it on "Content"? am I missing something on the extension config?

like image 903
Raúl Escudero Avatar asked Nov 20 '12 10:11

Raúl Escudero


1 Answers

I'm afraid I didn't test this but you should be able to use:

Extensions.YourExt.getConfigurationItem = function (itemName, editorName)
{
    var editor = $config.Editors[editorName].configuration;
    if (editor)
    {
        var confXml = $xml.getNewXmlDocument(editor);
        var confObj = $xml.toJson(confXml);

        if (confObj[itemName])
            return confObj[itemName];
        else
            return "";
    }
}

You can then use it in the following way:

$this.getConfigurationItem("YOUR_CONFIG_ITEM_NAME", "YOUR_EDITOR_NAME").toString();

In your extension configuration (below the <theme> node) you can enter your own configuration values:

<customconfiguration>
  <clientconfiguration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge">
  <YOUR_CONFIG_ITEM_NAME>The value</YOUR_CONFIG_ITEM_NAME>

Can you confirm :)

like image 125
johnwinter Avatar answered Sep 29 '22 13:09

johnwinter