邓_phpcms_二次开发_留言板

=================================================================•在 phpcms modul

=================================================================

•在 phpcms/modules 目录下创建文件夹,并将其命名为guestbook
 
classes  为模块类库包
functions 为模块函数库包
templates 为模块模板包 这里通常放置含有权限控制的控制器模板,也就是后台模板。
Install
Uninstall
Index.php
Guestbook.php
如果您的模块有单独的前台模版,你需要在phpcms/templates/default下创建一个您的模块同名目录来放置前台模板,“default”为你的风格包名称,我们默认适用default。
 --------------------------------------------------------------------------------------------
•添加外链栏目,指向记事本的控制器
•添加add.html模板,添加留言
•显示留言以及回复
 --------------------------------------------------------------------------------------------
•Config.inc.php

<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
$module = 'guestbook';
$modulename = '留言板';
$introduce = '留言模块';
$author = '个人团队';
$authorsite = 'http://www.phpcms.cn';
$authoremail = '';

?>

 ---------------------------------------------------------------------------------------------
路径:phpcms/modules/guestbook/install/extention.inc.php

<?php
//是否在后台主导航条上
$guestbook=$menu_db->get_one(array('name'=>'guestbook','parentid'=>'0'));
if($guestbook)
{
$parentid=$guestbook['id'];
}
else
{
$parentid=$menu_db->insert(
array(
'name'=>'a1',
'parentid'=>0,
'm'=>'guestbook',
'c'=>'index',
'a'=>'init',
'data'=>'',
'listorder'=>'10',
'display'=>'1'
),true);
}

//左侧主菜单
$id=$menu_db->insert(
array(
'name'=>'a2',
'parentid'=>$parentid,
'm'=>'guestbook',
'c'=>'guestbook',
'a'=>'init',
'data'=>'',
'listorder'=>'1',
'display'=>'1'
),true);
//左侧菜单项
$idd=$menu_db->insert(
array(
'name'=>'a3',
'parentid'=>$id,
'm'=>'guestbook',
'c'=>'guestbook',
'a'=>'guestbook_list',
'data'=>'',
'listorder'=>'1',
'display'=>'1'
),true);

$language =array(
'a1'=>'留言板',
'a2'=>'留言板',
'a3'=>'留言列表'
);


?>

 -----------------------------------------------------------
添加模块module.sql
 
路径:phpcms/modules/guestbook/install/module.php
 

INSERT INTO `phpcms_module` VALUES ('guestbook', '留言板', '', '0', '1.0', '', 'array (\n 1 => \n array (\n \'is_post\' => \'1\',\n \'enablecheckcode\' => \'0\',\n ),\n)', '0', '0', '2010-09-06', '2010-09-06');

----------------------------------------------------------------------------------------
建表guestbook.sql
路径:phpcms/modules/guestbook/install/guestbook.sql
 
DROP TABLE IF EXISTS `v9_guestbook`;
CREATE TABLE `v9_guestbook` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`author` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`cellphone` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`qq` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`msn` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`addtime` INT NULL ,
`ip` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`reply_admin` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`reply_content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
`reply_time` INT NULL ,
`status` INT NULL DEFAULT '-1')
 ENGINE = MYISAM ;
 
insert into v9_guestbook(title,content,author,cellphone) values
('ss','tt','admin','122'),
('jjj','hh','admin','120'),
('ggg','nnnn','admin','133');
 -----------------------------------------------------------------------
Uninstall卸载
 
路径:phpcms/modules/guestbook/uninstall
•model.php
•extension.inc.php
•guestbook.sql
 
--------------------------------------------------------------------------
后台控制器guestbook.php
路径:phpcms/modules/guestbook/guestbook.php

<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
class guestbook extends admin {
function __construct() {
parent::__construct();
$this->db = pc_base::load_model('guestbook_model');
}
public function guestbook_list()
{
$infos=$this->db->select();
include $this->admin_tpl('guestbook_list');
}
public function guestbook_edit()
{
}
public functionguestbook_del()
{
}
}

?>

------------------------------------------------------------------

后台模板guestbook_list.tpl.php
路径:phpcms/modules/guestbook/
•include $this->admin_tpl('header', 'admin');
-----------------------------------------------------------------
搜索部分

<form name="searchform" action="" method="get" >
<input type="hidden" value='guestbook' name="m">
<input type="hidden" value='guestbook' name="c">
<input type="hidden" value='guestbook_list'name="a">
<table width="100%" cellspacing="0" class="search-form">
<tbody>
<tr>
<td>
<div class="explain-col">
标题:<input name="title" type="text" value="<?php if(isset($_GET['title'])) {echo $_GET['title'];}?>" class="input-text" />
姓名:<input name="author" type="text" value="<?php if(isset($_GET['author'])) {echo $_GET['author'];}?>" class="input-text" />
手机:<input name="cellphone" type="text" value="<?php if(isset($_GET['cellphone'])) {echo $_GET['cellphone'];}?>" class="input-text" />
QQ:<input name="qq" type="text" value="<?php if(isset($_GET['qq'])) {echo $_GET['qq'];}?>" class="input-text" />
<input type="submit" name="search" class="button" value="<?php echo L('search')?>" />
</div>
</td>
</tr>
</tbody>
</table>

 ---------------------------------------------------
guestbook/install/model.php

<?php
defined('IN_PHPCMS') or exit('Access Denied');
defined('INSTALL') or exit('Access Denied');
return array('guestbook');
?>

 
 
------------------------------
 
 
您可能有感兴趣的文章
phpcms模块开发简易好代码教程

phpcms常用函数

phpcms学习总结

PHPCMS V9完全开发介绍

PHPCMS网站二次开发配置要点