我已經加入從博客條目的摘錄:從插件內部
插件參數從一個插件外從內側
$plugin = &JPluginHelper::getPlugin('exampleType', 'example');
$pluginParams = new JParameter($plugin->params);
$param = $pluginParams->get('paramName', 'defaultValue');
模塊參數
$param = $this->params->get('paramName', 'defaultValue');
插件參數一個模塊
從模塊外部
$module = &JModuleHelper::getModule('example');
$moduleParams = new JParameter($module->params);
$param = $moduleParams->get('paramName', 'defaultValue');
組件參數個
模塊參數從組件內從組件外
$componentParams = &JComponentHelper::getParams('com_example');
$param = $componentParams->get('paramName', 'defaultValue');
模板參數
$componentParams = &JComponentHelper::getParams('com_example');
$param = $componentParams->get('paramName', 'defaultValue');
組件參數從模板
內 從模板外
$param = $this->params->get('paramName');
模板參數從被包含的文件
jimport('joomla.filesystem.file');
$mainframe = &JFactory::getApplication();
$params = $mainframe->getParams(JFile::read(JURI::root() .'/templates/template_name/params.ini'));
$param = $params->get('paramName', 'defaultValue');
模板參數的Joomla框架
// Get params.ini relative to the current file location (use your own relative path here)
$paramsFile = dirname(__FILE__) . '/../../params.ini';
// Only continue if the file exists
if(file_exists($paramsFile)) {
// Get contents from params.ini file
$iniString = file_get_contents($paramsFile);
// Escape double quotes in values and then double-quote all values (because Joomla doesn't do that for us..)
$iniQuoted = preg_replace('/=(.*)\\n/', "=\"$1\"\n", addcslashes($iniString, '"'));
// Parse the ini string to an associative array
$iniParsed = parse_ini_string($iniQuoted);
} else {
$iniParsed = '';
}
// Set params to obtained values or empty array
$params = (!empty($iniParsed)) ? $iniParsed : array();
// Get param value from array
$param = $params['paramName'];