温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

phpcms V9 自定义添加 全局变量{DIY_PATH}方法

发布时间:2020-05-24 05:49:58 来源:网络 阅读:673 作者:gutaotao1989 栏目:web开发

前言:目前V9版本新增{JS_PATH},{CSS_PATH},{IMG_PATH}三个全局变量,样式图片脚本分开路径,确实达到了一定在后台管理方便的目的,但是个人感觉并不十分便捷

优势:可实现自定义模板分离,与default模板p_w_picpaths/js/css文件分开存放,方便管理,并实现自定义模板与后台样式分离

实现方法如下:


语言项修改文件,根目录/phpcms/languages/zh-cn/admin.lang.php

在文件167行

$LANG['setting_img_path'] = '图片路径';

之下添加

$LANG['setting_skin_path'] = '自定义皮肤路径';

语句,增加对应自定义模板路径语言项


修改配置文件,根目录/phpcms/modules/admin/functions/global.func.php

在文件42行

if(in_array($k,array

('js_path','css_path','img_path','p_w_upload_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','admin_url')))................

找到'img_path',在之后添加'skin_path',注意格式


修改后台显示模板文件,根目录/phpcms/modules/admin/functions/templates/setting.tpl.php

在文件12行

$("#img_path").formValidator({onshow:"<?php echo L('setting_input').L('setting_img_path')?>",onfocus:"<?php echo L('setting_img_path').L('setting_end_with_x')?>"}).inputValidator({onerror:"<?php echo L('setting_img_path').L('setting_input_error')?>"}).regexValidator({regexp:"(.+)\/$",onerror:"<?php echo L('setting_img_path').L('setting_end_with_x')?>"});

之下添加

$("#diy_path").formValidator({onshow:"<?php echo L('setting_input').L('setting_diy_path')?>",onfocus:"<?php echo L('setting_diy_path').L('setting_end_with_x')?>"}).inputValidator({onerror:"<?php echo L('setting_diy_path').L('setting_input_error')?>"}).regexValidator({regexp:"(.+)\/$",onerror:"<?php echo L('setting_diy_path').L

('setting_end_with_x')?>"});

在文件67-70行

<tr>

    <th width="120"><?php echo L('setting_img_path')?></th>

    <td class="y-bg"><input type="text" class="input-text" name="setconfig[img_path]" id="img_path" size="50" value="<?php echo IMG_PATH?>" /></td>

  </tr>

<tr>

之下添加

<tr>

    <th width="120"><?php echo L('setting_diy_path')?></th>

    <td class="y-bg"><input type="text" class="input-text" name="setconfig[diy_path]" id="diy_path" size="50" value="<?php echo DIY_PATH?>" /></td>

</tr>

配置文件缓存修改,根目录/caches/configs/system.php

在文件57行

'img_path' => 'http://www.iuuva.cn/statics/p_w_picpaths/',

之下添加

'diy_path' => '', //自定义路径

配置文件 根目录/phpcms/base.php

在文件49行

define('IMG_PATH',pc_base::load_config('system','img_path'));

之下添加

define('DIY_PATH',pc_base::load_config('system','diy_path'));


至此自定义添加全局变量{DIY_PATH}完毕,可后台更改自定义模板相关文件路径

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI