igaofen

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
我给出一个phpcms2007自定义字段在各个模块的调用方法吧,而且给留言本或者其他模块加自定义字段也完全类似。会php编程的看起来应该很好理解,不会的只能照着做了。
下面以给评论模块加自定义字段功能为例进行讲解(请注意下文中提到的“上面”和“下面”,不要错位):
1、修改 ./comment/admin/menu.inc.php

 

 

 $menu[$mod][] = array("模块配置","?mod=".$mod."&file=setting");

 

下加入一行

 

 $menu[$mod][] = array("自定义字段","?mod=phpcms&file=field&action=manage&tablename=".$CONFIG['tablepre']."comment");

 

2、修改 ./comment/include/common.inc.php

 

 include MOD_ROOT.'/include/global.func.php';

 

下加入2行

 

 require_once PHPCMS_ROOT.'/include/field.class.php';
$field = new field($CONFIG['tablepre'].'comment');

 

3、修改 ./comment/post.php

 

 $enabledkey = explode(",",$MOD['enabledkey']);

 

上面加入一行

 

 $field->check_form();

 

 

 if($passed == 1) update_comments($keyid, $itemid, 1);

 

上面加入2行

 

 $cid = $db->insert_id();
$field->update("cid=$cid");

 

4、修改 ./comment/list_js.php

 

 include template('comment', 'comment_submit');

 

上面加入一行

 

 $fields = $field->get_form('$title:$input $tool $note <br/>');

 

5、修改 ./comment/index.php

 

 include template($mod, 'index');

 

上面加入一行

 $fields = $field->get_form('$title:$input $tool $note <br/>');

6、修改模板 ./templates/default/comment/comment_submit.html

 

 

 <!--{if $MOD['enablecheckcode'] }-->验证码:

 

上面加入一行

 

 {$fields}

 

7、修改模板 ./templates/default/comment/index.html

 

 <!--{if $MOD['enablecheckcode'] }-->验证码:

 

上面加入一行

 

 {$fields}

 

8、修改模板 ./templates/default/comment/tag_comment_list.html

 

 <!--{loop $comments $comment}-->

 

下面适当地方加入类似

 

 QQ:{$comment[my_qq]}

 

的代码,my_qq为自定义字段名

9、至此代码都修改完毕,请进后台点“功能模块”,在左边导航找到“评论管理”,然后点“自定义字段”,进去加字段吧

如果有的模块需要实现按自定义字段搜索的可以参考
./module/article/search.inc.php 和搜索模板 ./templates/default/article/search.html
posted on 2009-09-07 00:54  igaofen  阅读(416)  评论(0编辑  收藏  举报