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 分享