最近遇到很多人需要定义全局变量,比如联系方式,公司地址,QQ等,所以,我写了这个方案,仅仅是自己用而已:
首先,要在caches/configs/system.php里写上要定义的变量,比如:
‘qq’ => ‘11111111’,
然后phpcms/base.php里定义qq变量
找到//定义网站根路径
在下面写上:
define('QQ',pc_base::load_config('system','qq'));
1
define('QQ',pc_base::load_config('system','qq'));
至此,变量的定义就完成了,就可以使用{QQ}来调用
下面的修改是完善后台管理的:
打开:phpcms\modules\admin\functions\global.func.php
找到:
设置config文件里的
if(in_array($k,array('js_path','css_path','img_path','attachment_stat'
这一段
在里面加上’,’qq
变成
if(in_array($k,array('js_path','qq','css_path','img_path','attachment_stat
然后到
phpcms\modules\admin\templates\setting.tpl.php
里写上表单:
12行找到
("#img_path").formValidator({onshow:"",onfocus:""}).inputValidator({onerror:""}).regexValidator({regexp:"(.+)\/",onerror:"<?php echo L('setting_img_path').L('setting_end_with_x')?>"});
下面另起一行写入
("#qq").formValidator({onshow:"",onfocus:""}).inputValidator({onerror:""}).regexValidator({regexp:"(.+)\",onerror:"<?php echo L('setting_qq').L('请输入数字')?>"});
72行找到:
<tr>
<th width="120"><?php echo L('setting_upload_url')?></th>
<td><input type="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_qq')?></th>
<td><input type="text" name="setconfig[qq]" id="qq" size="50" value="<?php echo $qq?>" /></td>
</tr>
然后这样就可以了,但是缺少个语言项,到这里加:
phpcms\languages\zh-cn最下面的?>上面加上
$LANG['setting_qq'] = 'QQ';
至此,后台管理也写好 ,就可以到后台-设置-基本设置里,看到你加的表单,就可以管理了
网友评论