修改网站system.php配置文件
文件路径:/caches/configs/system.php
在第30行左右,
1 |
|
在此行下添加配置,我这里是一个qq咨询的地址,结果如下:
1 2 |
|
修改网站base.php配置文件
文件路径:/phpcms/base.php
在第51行左右,
1 |
|
在此行下添加配置如下:
1 2 3 4 |
|
到这一步之后,就已经可以在模板中调用了,调用方法{CHAT_PATH},模板自动解析。
为了方便以后修改修护,不用每次都去改代码,我们去修改一下后台模板来实现。
修改网站setting.tpl.php文件
文件路径:/phpcms/modules/admin/templates/setting.tpl.php
在第73行左右,
<tr>
<th width="120"><?php echo L('setting_upload_url')?></th>
<td class="y-bg"><input type="text" class="input-text" name="setconfig[upload_url]" id="upload_url" size="50" value="<?php echo $upload_url?>" /></td>
</tr>
在此行下添加配置如下:
<tr>
<th width="120"><?php echo L('setting_upload_url')?></th>
<td class="y-bg"><input type="text" class="input-text" name="setconfig[upload_url]" id="upload_url" size="50" value="<?php echo $upload_url?>" /></td>
</tr>
<tr>
<th width="120"><?php echo L('setting_chat_path')?></th>
<td class="y-bg"><input type="text" class="input-text" name="setconfig[chat_path]" id="chat_path" size="50" value="<?php echo $chat_path?>" /></td>
</tr>
修改网站admin.lang.php文件,添加语言包
文件路径:/phpcms/languages/zh-cn/admin.lang.php
在第170行左右,
1 |
|
在此行下添加配置如下:
1 2 |
|
修改global.func.php文件set_config函数
文件路径:/phpcms/languages/zh-cn/admin.lang.php
在第42行左右,在’img_path’后面添加’chat_path’,这样才能保存设置
if(in_array($k,array('js_path','css_path','img_path','attachment_stat','admin_log','gzip','errorlog','phpsso','phpsso_appid','phpsso_api_url','phpsso_auth_key','phpsso_version','connect_enable', 'upload_url','sina_akey', 'sina_skey', 'snda_enable', 'snda_status', 'snda_akey', 'snda_skey', 'qq_akey', 'qq_skey','qq_appid','qq_appkey','qq_callback','admin_url'))) {
修改后结果如下:
if(in_array($k,array('js_path','css_path','img_path','chat_path','attachment_stat','admin_log','gzip','errorlog','phpsso','phpsso_appid','phpsso_api_url','phpsso_auth_key','phpsso_version','connect_enable', 'upload_url','sina_akey', 'sina_skey', 'snda_enable', 'snda_status', 'snda_akey', 'snda_skey', 'qq_akey', 'qq_skey','qq_appid','qq_appkey','qq_callback','admin_url'))) {
PHPCMS V9中添加自定义全局变量就是这么添加的,它的优点是方便维护,缺点是要修改几个文件,在更新PHPCMS V9时可能会被替换,如果被替换就需要重新来一遍。