PHPCMS 如何添加模块?

PHPCMS 如何添加模块?

phpcms 如何添加模块?

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

PHPCMS 如何添加模块?

  • classes 为模块类库包

    立即学习PHP免费学习笔记(深入)”;

  • functions 为模块函数库包

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

然后创建模块控制器类;

<?php     defined(&#39;IN_PHPCMS&#39;) or exit(&#39;No permission resources.&#39;);     class mytest     {         function __construct(){}         public function init()         {             $myvar = &#39;hello world!&#39;;             echo $myvar;         }         public function mylist()         {             $myvar = &#39;hello world! This is an example!&#39;;             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-&gt;admin_tpl('mytest_admin_list'); }

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

<?php defined(&#39;IN_PHPCMS&#39;) or exit(&#39;No permission resources.&#39;); pc_base::load_sys_class(&#39;model&#39;, &#39;&#39;, 0); class test_model extends model {     public function __construct()     {         $this->db_config = pc_base::load_config('database');         $this-&gt;db_setting = 'default';         $this-&gt;table_name = 'test';         parent::__construct();     }  } ?&gt;

推荐教程:《PHPCMS教程

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享