要为PHPCMS在管理中心里面增加配置项,并不需要修改数据库。下面以备案编号作为例子,添加一个站点自定义配置项。
1. 语言项的增加(中文为例),在phpcms/languages/zh-cn/admin.lang.php中合适位置加入:
$LANG['site_other_settings'] = '其他配置'; $LANG['site_other_icp_number'] = '备案编号';
2. 后台管理的操作文件:
2.1 在添加文件phpcms/modules/admin/templates/site_add.tpl.php中合适位置加入:
<!--?php echo L('site_other_settings')?-->
<table class="table_form" width="100%">
<tbody>
<tr>
<th valign="top" width="130">
<?php echo L('site_other_icp_number')?>:
</th>
<td class="y-bg"><input type="text" class="input-text" name="setting[icp_number]" id="icp_number" value="" size="30"/></td>
</tr>
</tbody>
</table>
<div class="bk15"></div>
2.2 在更新文件phpcms/modules/admin/templates/site_edit.tpl.php中合适位置加入:
<!--?php echo L('site_other_settings')?-->
<table class="table_form" width="100%">
<tbody>
<tr>
<th valign="top" width="130">
<?php echo L('site_other_icp_number')?>:
</th>
<td class="y-bg"><input type="text" class="input-text" name="setting[icp_number]" id="icp_number" value="<?php echo $setting['icp_number'] ? $setting['icp_number'] : '' ?>" size="30"/></td>
</tr>
</tbody>
</table>
<div class="bk15"></div>
3. 添加自定义函数,在phpcms/libs/functions/extention.func.php文件中加入:
function site_setting($code)
{
$siteinfo = siteinfo(get_siteid());
$setting = string2array($siteinfo['setting']);
return $setting[$code];
}
4. 模板文件显示,在文件phpcms/templates/{what_tpl}/content/footer.html中加入:
{site_setting('icp_number')}