Joomla下利用configuration.php存儲簡單數(shù)據(jù)
更新時間:2010年05月19日 23:45:34 作者:
Joomla下利用configuration.php存儲簡單數(shù)據(jù)的代碼,需要的朋友可以參考下。
寫入過程
// Get the path of the configuration file
$fname = JPATH_CONFIGURATION.DS.'configuration.php';
// clear cache
$cache = JFactory::getCache();
$cache->clean();
// Update the credentials with the new settings
$config =& JFactory::getConfig();
$config->setValue('config.custom_var', 'xxx');
// Get the config registry in PHP class format and write it to configuation.php
jimport('joomla.filesystem.file');
if (!JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) {
die(JText::_('ERRORCONFIGFILE'));
}
提取過程
global $mainframe;
$mainframe->getCfg('custom_var');
復制代碼 代碼如下:
// Get the path of the configuration file
$fname = JPATH_CONFIGURATION.DS.'configuration.php';
// clear cache
$cache = JFactory::getCache();
$cache->clean();
// Update the credentials with the new settings
$config =& JFactory::getConfig();
$config->setValue('config.custom_var', 'xxx');
// Get the config registry in PHP class format and write it to configuation.php
jimport('joomla.filesystem.file');
if (!JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) {
die(JText::_('ERRORCONFIGFILE'));
}
提取過程
復制代碼 代碼如下:
global $mainframe;
$mainframe->getCfg('custom_var');
您可能感興趣的文章:
- joomla實現(xiàn)注冊用戶添加新字段的方法
- Joomla數(shù)據(jù)庫操作之JFactory::getDBO用法
- Joomla使用Apache重寫模式的方法
- Joomla開啟SEF的方法
- Joomla簡單判斷用戶是否登錄的方法
- Joomla實現(xiàn)組件中彈出一個模式(modal)窗口的方法
- joomla組件開發(fā)入門教程
- joomla數(shù)據(jù)庫操作示例代碼
- CKeditor與syntaxhighlight打造joomla代碼高亮
- joomla內(nèi)置的表單驗證功能使用方法
- 了解Joomla 這款來自國外的php網(wǎng)站管理系統(tǒng)
- Joomla語言翻譯類Jtext用法分析
相關(guān)文章
PHP實現(xiàn)的權(quán)重算法示例【可用于游戲根據(jù)權(quán)限來隨機物品】
這篇文章主要介紹了PHP實現(xiàn)的權(quán)重算法,可用于游戲根據(jù)權(quán)限來隨機物品,涉及php數(shù)組遍歷、隨機數(shù)處理及數(shù)值運算相關(guān)操作技巧,需要的朋友可以參考下2019-02-02