How to access values from alfresco-global.properties in freemarker and YUI javascript files

时光怂恿深爱的人放手 提交于 2019-12-12 00:08:37

问题


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.


回答1:


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!
});


来源:https://stackoverflow.com/questions/11366978/how-to-access-values-from-alfresco-global-properties-in-freemarker-and-yui-javas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!