前言:目前V9版本新增{JS_PATH},{CSS_PATH},{IMG_PATH}三個全局變量,樣式圖檔腳本分開路徑,确實達到了一定在背景管理友善的目的,但是個人感覺并不十分便捷
優勢:可實作自定義模闆分離,與default模闆images/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','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','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>
<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/images/',
'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}完畢,可背景更改自定義模闆相關檔案路徑
本文轉自 gutaotao1989 51CTO部落格,原文連結:http://blog.51cto.com/taoyouth/1609231