帝国CMS二次开发留言板自定义字段教程

整理了下我的修改步骤(实现留言板增加qq、留言主题字段)

要改的文件有:

e\enews\gbookfun.php

e\tool\gbook\index.php

e\admin\tool\gbook.php

e\admin\tool\ReGbook.php

e\data\template\gbooktemp.txt

e\class\functions.php

1、进入phpmyadmin后台,在数据库enewsgbook表(留言板数据表)中增加字段,

比如: qq、theme,

2、打开e\enews\gbookfun.php,

1、在13行左右的地方插入下面代码:

$theme=RepPostStr($add[theme]);
//myadd

$qq=RepPostStr($add[qq]);
//myadd

 

2、在60行左右找到 $empire->query(“insert into 的语句中的相应的位置加入相应的代码。

3、打开e\tool\gbook\index.php,

1、在51行左右找到“$query=”select …”查询语句中适当位置加入字段,如:,theme,qq

2、在135行左右找到“发布者: <?=$r[name]?>……”, 在要显示字段的地方加入<?=$r[theme]?> ,<?=$r[qq]?> 调用显示就行了。

3、在170行左右找到“<form action=”../../enews/index.php”” 在表单中加入相应的Input语句就行了。例如在联系电话这行下面插入:

<tr bgcolor=
“#FFFFFF”>

<td>公司名称:</td>

<td height=
“23”><input name=
“theme” type=
“text” id=
“theme” size=
“80”/></td>

</tr><!–myadd–>

<tr
class=
“ly2”>

<td
class=
“lytxt”>性&nbsp;&nbsp;&nbsp;别:</td>

<td>

<INPUT name=
“qq” value=
“先生”> 先生&nbsp;

</td>

</tr><!–myadd–>

 

4、后台:打开e\admin\tool\gbook.php,

在50行左右找到“$query=”select”查询语句,在末尾加入字段:,theme,qq

在119行左右的找到“<table width=”700″ …<td width=”32%” height=”23″>发布者:……”, 在要显示字段的地方加入“<?=$r[theme]?> ,<?=$r[qq]?>

调用显示就行了。

5、后台回复页面:打开e\admin\tool\ReGbook.php

直接在页面加入<?=$r[theme]?> ,<?=$r[qq]?>就行了。如在51行左右的“留言发表者”该行下面插入两行代码:

<tr bgcolor=
“#FFFFFF”>

<td height=
“25”>QQ:</td>

<td height=
“25”>

<?=$r[qq]?>

</td>

</tr>

<tr bgcolor=
“#FFFFFF”>

<td height=
“25”>留言主题:</td>

<td height=
“25”>

<?=$r[theme]?>

</td>

</tr>

 

6、到此前、后台都已经可以了,下面进一步修改:

1、打开e/data/template/gbooktemp.txt文件,约51行找到“$query=”select…”查询语句,在适当位置加入字段,如:,theme,qq

2、打开e/class/functions.php文件,约2940行找到:“$listtemp_center=str_replace(“[!–retext–]”,”<?=\$r[retext]?>”,$listtemp_center);”,在改

行下面插入相应写法的代码,如:

$listtemp_center=str_replace(
“[!–theme–]”,
“<?=\$r[theme]?>”,$listtemp_center);

$listtemp_center=str_replace(
“[!–qq–]”,
“<?=\$r[qq]?>”,$listtemp_center);

 

3、修改下留言板模板就oK了。