Home > Article > CMS Tutorial > How to add modules to PHPCMS?
PHPCMS How to add modules?
First create the module directory, under which you need to create the "classes", "functions" and "templates" directories;
classes is the module class library package
functions is the module function library package
templates is the module template package, usually containing permission control Controller template, also known as background template.
Then create the module controller class;
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class mytest { function __construct(){} public function init() { $myvar = 'hello world!'; echo $myvar; } public function mylist() { $myvar = 'hello world! This is an example!'; echo $myvar; } } ?>
Then load the front-end template and back-end template;
public function init() { $myvar = 'hello world!'; echo $myvar; include template('test', 'index'); }
public function init() { $myvar = 'oh,i am phpcmser'; echo $myvar; include $this->admin_tpl('mytest_admin_list'); }
Finally create the database model class.
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_sys_class('model', '', 0); class test_model extends model { public function __construct() { $this->db_config = pc_base::load_config('database'); $this->db_setting = 'default'; $this->table_name = 'test'; parent::__construct(); } } ?>
Recommended tutorial: "PHPCMS Tutorial"
The above is the detailed content of How to add modules to PHPCMS?. For more information, please follow other related articles on the PHP Chinese website!