Have a question about CiviCRM? Get it answered quickly at the new CiviCRM Stack Exchange Q+A siteThis forum was archived on 25 November 2017. Learn more.How to get involved.What to do if you think you've found a bug.
<script>//CRM is a new global object introduced by Colemans for 4.3, I use it as a namespace to store civi variablesCRM.config = {crmAPI entity="setting"}; // implicit action getconsole.log (CRM.config.monetaryDecimalPoint);//or if you want only one value, this should work toovar seperator = {crmAPI entity="setting" action="getvalue" return="monetaryDecimalPoint"};</script>
function calculatedPaymentAmount( ) { var thousandMarker = {/literal}{crmAPI entity="setting" action="getvalue" group="CiviCRM Localization" return="monetary_thousand_separator"}{literal};
The custom separator is a pain with the xml so 3 options (or a combo of them)1) Store settings metadata as a php array (as X suggested). 2) Store custom separated settings as a serialised array rather than a serialised custom separated string3) Store custom separated settings as a serialised json string rather than a serialised custom separated string 4) Store custom separated settings as a non-serialised json string (but of course the other values would be serialised still (!) Personally I'm leaning mostly towards #2 with #1 being possibly worth doing but not necessarily in response to this.
Namely, wouldn't it be better to simply generate a config.cache.php that contains the $config (or in as a static in a "namespace" function) instead of a serialized in a db row in civicrm_cache (or memcache)?
As for the groups, are the name of the settings unique across all the groups? We could keep the groups in the db and "flatten" them in the config/api.setting (probably going to cost a few more requests if the config isn't saved in the cache file, but shouldn't happen too often)
7) most of the settings are pretty 'lean' but I wouldn't want to be loading up the big ones - e.g. country list , state_list as part of a generic cached settings array.
P.S if needed for big config items (eg countries list) might be a worthwhile improvement to add a magic __get() so the $config->country is only loaded when needed.