0

I have numerous custom variables in Alfresco's alfresco-global.properties file that I'd like to use throughout various freemarker ftl files as well as the various YUI files, which will greatly alter the behavior of Share and how it displays information.

I have the property values accessible through various javascript calls (for example, getNetworkName() will return the custom app.network.name variable set in the properties), but I am uncertain of how I'd expose these javascript functions to either freemarker or the YUI files, or if I even need to, as opposed to just accessing the variables directly.

Scott
  • 6,716
  • 9
  • 40
  • 46
  • Did you have a read of the similar question [Accessing values from Alfresco's Global Properties](http://stackoverflow.com/questions/10452800/accessing-values-from-alfrescos-alfresco-global-properties-file?rq=1)? – Gagravarr Jul 07 '12 at 11:05
  • Yep, work right next to the guy that asked that question, but that's just accessing it in the bean, not in YUI. – Scott Jul 09 '12 at 10:50
  • Step One - get the variables available to the repo (eg a custom repo bean). Step Two - expose that via a webscript. Step Three - pull that into YUI and consume – Gagravarr Jul 09 '12 at 14:06
  • By "pull that into YUI and consume" I assume you mean make an http request to the webscript, or does YUI simplify things? I can't seem to find any documentation on accessing webscripts via YUI, do you have any links? – Scott Jul 09 '12 at 18:07
  • 1
    Have a webscript that returns JSON, then get YUI to fetch it. Lots of bits of Share do that already for various things, so you ought to be able to find plenty of good examples to crib off in the Alfresco source code! – Gagravarr Jul 09 '12 at 19:11

1 Answers1

0

If you have defined global variables and functions you don't need to do anything special to access them from YUI.

You can optionally do something like this to take advantage of YUI's sandboxing ability so that each sandbox can't affect the other by changing the global configuration:

YUI_config = {
    app: {
      network: {
        name: 'foo' // or getNetworkName()
      }
    }
};

YUI().use('node', function (Y) {
    console.log(Y.config.app.network.name); // foo
    Y.config.app.network.name = 'bar';
});
YUI().use('tabview', function (Y) {
    console.log(Y.config.app.network.name); // still foo!
});
juandopazo
  • 6,283
  • 2
  • 26
  • 29
  • Is this in relation to Alfresco defined global variables (set in alfresco-global.properties), or YUI specific global variables? – Scott Jul 09 '12 at 11:03
  • This is just generic advice regarding YUI and configuration options – juandopazo Jul 09 '12 at 14:14
  • 1
    This explains how to access values from the share-config.xml which is in the share frontend layer but does not work for the alfresco-global.properties from the backend. – Florian Jul 16 '12 at 16:22