Joomla下利用configuration.php存儲(chǔ)簡(jiǎn)單數(shù)據(jù)
更新時(shí)間:2010年05月19日 23:45:34 作者:
Joomla下利用configuration.php存儲(chǔ)簡(jiǎn)單數(shù)據(jù)的代碼,需要的朋友可以參考下。
寫入過(guò)程
// 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'));
}
提取過(guò)程
global $mainframe;
$mainframe->getCfg('custom_var');
復(fù)制代碼 代碼如下:
// 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'));
}
提取過(guò)程
復(fù)制代碼 代碼如下:
global $mainframe;
$mainframe->getCfg('custom_var');
您可能感興趣的文章:
- joomla實(shí)現(xiàn)注冊(cè)用戶添加新字段的方法
- Joomla數(shù)據(jù)庫(kù)操作之JFactory::getDBO用法
- Joomla使用Apache重寫模式的方法
- Joomla開(kāi)啟SEF的方法
- Joomla簡(jiǎn)單判斷用戶是否登錄的方法
- Joomla實(shí)現(xiàn)組件中彈出一個(gè)模式(modal)窗口的方法
- joomla組件開(kāi)發(fā)入門教程
- joomla數(shù)據(jù)庫(kù)操作示例代碼
- CKeditor與syntaxhighlight打造joomla代碼高亮
- joomla內(nèi)置的表單驗(yàn)證功能使用方法
- 了解Joomla 這款來(lái)自國(guó)外的php網(wǎng)站管理系統(tǒng)
- Joomla語(yǔ)言翻譯類Jtext用法分析
相關(guān)文章
PHP的異常處理類Exception的使用及說(shuō)明
異常處理的基本思想是代碼在try代碼被調(diào)用執(zhí)行。如果try碼塊出現(xiàn)錯(cuò)誤,我們可以執(zhí)行一個(gè)拋出異常的處理2012-06-06PHP實(shí)現(xiàn)的權(quán)重算法示例【可用于游戲根據(jù)權(quán)限來(lái)隨機(jī)物品】
這篇文章主要介紹了PHP實(shí)現(xiàn)的權(quán)重算法,可用于游戲根據(jù)權(quán)限來(lái)隨機(jī)物品,涉及php數(shù)組遍歷、隨機(jī)數(shù)處理及數(shù)值運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下2019-02-02PHP下操作Linux消息隊(duì)列完成進(jìn)程間通信的方法
當(dāng)我們開(kāi)發(fā)的系統(tǒng)需要使用多進(jìn)程方式運(yùn)行時(shí),進(jìn)程間通信便成了至關(guān)重要的環(huán)節(jié)。消息隊(duì)列(message queue)是Linux系統(tǒng)進(jìn)程間通信的一種方式。2010-07-07

PHP擴(kuò)展之kafka安裝應(yīng)用案例詳解
這篇文章主要介紹了PHP擴(kuò)展之kafka安裝應(yīng)用案例詳解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
2021-09-09