Try way I’m using:
Step 1— Settings Template.
Create Template and link with it some TVs (this will be settings). I use "ini_" prefix for settings TV.
FOR EXAMPLE: if you want global setting "color", you have to create TV with name "ini_color", type "dropdown" and elements "red||green||blue"
Step 2 — Settings Document
Create document with this Template and set alias to "settings" (Now you can easy edit all your additional settings)
Step 3 — Include settings into MODx settings array
A. Open folder manager\includes
B. In file document.parser.class.inc.php, line 207 (MODx 0.9.6), in getSettings function, after:
// store base_url and base_path inside config array
$this->config['base_url']= MODX_BASE_URL;
$this->config['base_path']= MODX_BASE_PATH;
$this->config['site_url']= MODX_SITE_URL;
Add:
include('extra.config.inc.php');
C. in manager\includes create file extra.config.inc.php and fill it by:
<?php
// set static variables
$this->config['ini_currency'] = 'usd'; // Site default currency
$this->config['ini_phone'] = '+79284517838'; // Phone
$this->config['ini_address'] = 'Sochi, Mira street, 21'; // Address
// set variables from settings page
$site_content = $this->getFullTableName('site_content');
$site_tmplvars = $this->getFullTableName('site_tmplvars');
$site_tmplvar_contentvalues = $this->getFullTableName('site_tmplvar_contentvalues');
$sql = "SELECT tv.name,tvc.value FROM $site_tmplvar_contentvalues AS tvc
LEFT JOIN $site_tmplvars AS tv ON tv.id=tvc.tmplvarid
LEFT JOIN $site_content AS c ON c.id=tvc.contentid
WHERE c.alias='settings';";
$rs = $this->db->query($sql);
while($row = $this->db->getRow($rs)) {
$this->config[$row['name']] = $row['value'];
}
mysql_free_result($rs);
?>
This little script links your static settings and settings from document with alias "settings" with MODx settings array and you can use it everywere by calls:
1.
$modx->config['ini_mysetting']
— in snippets/modules/plugins
2.
— in documents/templates/chunks
Add settings how you need by linking new TVs to Settings Template and Enjoy!
Good Luck!