国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

PHPCMS模塊的安裝和卸載

2024-09-10 07:16:06
字體:
供稿:網(wǎng)友

PHPCMS模塊的安裝和卸載

假設(shè)我安裝的模塊名為 "mytest"

步驟如下:

1.新建文件夾 /phpcms/modules/mytest,在 mytest 下新建3個文件夾和2個文件,如上圖紅色線框.

install:安裝文件存放文件夾

uninstall:卸載文件存放文件夾

templates:后臺模板文件存放文件夾

index.php:前臺控制器

mytest_admin.php:后臺控制器

index.php 文件內(nèi)容:

  1. <?php   
  2. defined('IN_PHPCMS'or exit('No permission resources.');   
  3. class index {   
  4.     public function init(){   
  5.         echo '模塊mytest前臺控制器的默認(rèn)方法';   
  6.     }   
  7.     public function test(){   
  8.         include template('mytest''1'); // 輸出模板:mytest 模塊下的 1.html (1.html內(nèi)容請往下看!)   
  9.     }   
  10. }  
  11. ?> 

mytest_admin.php 文件內(nèi)容:

  1. <?php   
  2. defined('IN_PHPCMS'or exit('No permission resources.');   
  3. pc_base::load_app_class('admin''admin', 0);   
  4. class mytest_admin extends admin {   
  5.        
  6.     public function __construct() {   
  7.         parent::__construct(); // 必須先執(zhí)行父類 admin 的構(gòu)造方法   
  8.     }   
  9.        
  10.     public function init(){   
  11.         include $this->admin_tpl('index'); // 模塊mytest的后臺菜單---默認(rèn)頁:mytest/templates/index.tpl.php   
  12.     }   //Vevb.com  
  13.        
  14.     public function setting(){   
  15.         include $this->admin_tpl('setting'); // 模塊mytest的后臺菜單---設(shè)置頁:mytest/templates/setting.tpl.php   
  16.     }   
  17.        
  18. }   
  19. ?> 

templates/index.tpl.php

  1. <?php defined('IN_ADMIN'or exit('No permission resources.');?>   
  2. <?php include $this->admin_tpl('header''admin');?>   
  3. 模塊mytest的后臺菜單---默認(rèn)頁   
  4. </body>   
  5. </html> 

templates/setting.tpl.php

  1. <?php defined('IN_ADMIN'or exit('No permission resources.');?>   
  2. <?php include $this->admin_tpl('header''admin');?>   
  3. 模塊mytest的后臺菜單---設(shè)置頁   
  4. </body>   
  5. </html> 

2.在 mytest/install/ 下,新建 languages/zh-cn/mytest.lang.php、templates/1.html、config.inc.php、extension.inc.php、model.php、module.sql、mytest.sql 文件.

/phpcms/modules/mytest/install/languages/zh-cn/mytest.lang.php:語言文件,此文件將被復(fù)制到 /phpcms/languages/zh-cn/mytest.lang.php.

  1. <?php 
  2. $LANG['setting_updates_successful'] = '配置更新完成'
  3. ?> 

/phpcms/modules/mytest/install/templates/1.html:前臺模板,此文件將被復(fù)制到 /phpcms/templates/default/mytest/1.html

前臺頁面訪問測試:www.survivalescaperooms.com/index.php?m=mytest&c=index&a=test  

/phpcms/modules/mytest/install/config.inc.php:模塊相關(guān)介紹信息

  1. <?php    
  2. defined('IN_PHPCMS'or exit('Access Denied');   
  3. defined('INSTALL'or exit('Access Denied');   
  4. $module = 'mytest';   
  5. $modulename = '我的測試模塊';   
  6. $introduce = '我的測試模塊cccccc';   
  7. $author = 'malinjie66 team';   
  8. $authorsite = 'http://www.survivalescaperooms.com';   
  9. $authoremail = 'malinjie66@126.com';   
  10. ?> 

/phpcms/modules/mytest/install/extension.inc.php:模塊后臺管理的菜單

  1. <?php   
  2. defined('IN_PHPCMS'or exit('Access Denied');   
  3. defined('INSTALL'or exit('Access Denied');   
  4. $parentid = $menu_db->insert(array('name'=>'mytest''parentid'=>'29''m'=>'mytest''c'=>'mytest_admin''a'=>'init''data'=>'''listorder'=>0, 'display'=>'1'), true); // 這個菜單會顯示在左側(cè)   
  5. $menu_db->insert(array('name'=>'mytest_setting''parentid'=>$parentid'm'=>'mytest''c'=>'mytest_admin''a'=>'setting''data'=>'''listorder'=>0, 'display'=>'1')); // 這個菜單會顯示在右側(cè)頁簽   
  6. $language = array('mytest'=>'測試XX''mytest_setting'=>'設(shè)置'); // 給菜單設(shè)置中文顯示詞   
  7. ?> 

/phpcms/modules/mytest/install/model.php:模型文件(該文件返回一個數(shù)組,所以可以有多個模型文件)

  1. <?php     
  2. defined('IN_PHPCMS'or exit('Access Denied');   
  3. defined('INSTALL'or exit('Access Denied');   
  4. return array('mytest'); // 模型文件 /phpcms/model/mytest_model.class.php 必須手動建立!內(nèi)容如下:   
  5. ?> 

/phpcms/model/mytest_model.class.php

  1. <?php   
  2. defined('IN_PHPCMS'or exit('No permission resources.');   
  3. pc_base::load_sys_class('model''', 0);   
  4. class mytest_model extends model {   
  5.     function __construct() {   
  6.         $this->db_config = pc_base::load_config('database'); // 加載數(shù)據(jù)庫配置   
  7.         $this->db_setting = 'default'// 連接默認(rèn)數(shù)據(jù)庫   
  8.         $this->table_name = 'mytest';  // 設(shè)置表名   
  9.         parent::__construct();         // 執(zhí)行 model 類的構(gòu)造方法   
  10.     }    
  11. }   
  12. ?> 

/phpcms/modules/mytest/install/module.sql:在module表中插入一條記錄(mytest模塊相關(guān)的信息)

  1. INSERT INTO `phpcms_module` (`module`, `name`, `url`, `iscore`, `version`, `description`, `setting`, `listorder`, `disabled`, `installdate`, `updatedate`) VALUES ('mytest''我的測試模塊''mytest/', 0, '1.0''我的測試模塊''', 0, 0, '2013-10-05''2013-10-12');  

/phpcms/modules/mytest/install/mytest.sql:mytest模塊要用到的表結(jié)構(gòu)

  1. DROP TABLE IF EXISTS `phpcms_mytest`;   
  2. CREATE TABLE IF NOT EXISTS `phpcms_mytest` (   
  3.   `id` int(10) unsigned NOT NULL auto_increment,   
  4.   `catid` int(10) unsigned NOT NULL default '0' COMMENT '欄目id',   
  5.   `siteid` mediumint(6) unsigned NOT NULL default '0' COMMENT '站點ID',   
  6.   `contentid` int(10) unsigned NOT NULL default '0' COMMENT '文章id',   
  7.   `total` int(10) unsigned NOT NULL default '0' COMMENT '總數(shù)',   
  8.   `n1` int(10) unsigned NOT NULL default '0',   
  9.   `n2` int(10) unsigned NOT NULL default '0',   
  10.   `n3` int(10) unsigned NOT NULL default '0',   
  11.   `lastupdate` int(10) unsigned NOT NULL default '0' COMMENT '最后更新時間',   
  12.   PRIMARY KEY  (`id`),   
  13.   KEY `total` (`total`),   
  14.   KEY `lastupdate` (`lastupdate`),   
  15.   KEY `catid` (`catid`,`siteid`,`contentid`)   
  16. ) TYPE=MyISAM;   

3.在 mytest/uninstall/ 下,新建 extension.inc.php、model.php、mytest.sql.

extension.inc.php 文件內(nèi)容:

  1. <?php   
  2. defined('IN_PHPCMS'or exit('Access Denied');   
  3. defined('UNINSTALL'or exit('Access Denied');   
  4. ?> 

model.php 文件內(nèi)容:

  1. <?php   
  2. defined('IN_PHPCMS'or exit('Access Denied');   
  3. defined('UNINSTALL'or exit('Access Denied');    
  4. return array('mytest');   
  5. ?> 

mytest.sql 文件內(nèi)容:

DROP TABLE IF EXISTS `phpcms_mytest`;  

訪問效果:

PHPCMS模塊的安裝和卸載

PHPCMS模塊的安裝和卸載

extention.inc.php  千萬不要寫成 extension.inc.php.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡山县| 屏南县| 平舆县| 普定县| 寿阳县| 上虞市| 大名县| 玉屏| 关岭| 嘉义县| 白玉县| 大理市| 东乡县| 广西| 涞源县| 建阳市| 九龙坡区| 元江| 龙州县| 尼勒克县| 乐东| 镇江市| 海盐县| 河间市| 建平县| 罗田县| 包头市| 棋牌| 富源县| 关岭| 会同县| 恩施市| 虞城县| 桓台县| 湟中县| 商丘市| 斗六市| 府谷县| 灵山县| 石台县| 天祝|