您的位置 首页 技术

PHPCMS 如何添加模块?

PHPCMS 如何添加模块? 首先创建模块目录,目录下需要创建“classes”、“functions”和“templates”目录; classes 为模块类库包 functio…

PHPCMS 如何添加模块?

首先创建模块目录,目录下需要创建“classes”、“functions”和“templates”目录;

Snipaste_2020-06-18_16-56-14.png

  • classes 为模块类库包

  • functions 为模块函数库包

  • templates 为模块模板包,通常放置含有权限控制的控制器模板,也就是后台模板。

然后创建模块控制器类;

<?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;        }    }?>

接着加载前台模板和后台模板;

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');}

最后创建数据库模型类即可。

<?phpdefined('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();    } }?>

推荐教程:《PHPCMS教程》

以上就是PHPCMS 如何添加模块?的详细内容,更多请关注24课堂在线网其它相关文章!

本文来自网络,不代表24小时课堂在线立场,转载请注明出处:https://www.24ketang.cn/82492.html

为您推荐

返回顶部