首頁  >  文章  >  CMS教程  >  PHPCMS 如何加入模組?

PHPCMS 如何加入模組?

Guanhui
Guanhui原創
2020-06-18 17:01:042889瀏覽

PHPCMS 如何加入模組?

PHPCMS 如何新增模組?

先建立模組目錄,目錄下需要建立「classes」、「functions」和「templates」目錄;

PHPCMS 如何加入模組?

  • classes 為模組類別庫包

  • 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 = &#39;hello world!&#39;;
    echo $myvar;
    include template(&#39;test&#39;, &#39;index&#39;);
}
public function init()
{
    $myvar = &#39;oh,i am phpcmser&#39;;
    echo $myvar;
    include $this->admin_tpl(&#39;mytest_admin_list&#39;);
}

最後建立資料庫模型類別即可。

<?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(&#39;database&#39;);
        $this->db_setting = &#39;default&#39;;
        $this->table_name = &#39;test&#39;;
        parent::__construct();
    }
 }
?>

推薦教學:《PHPCMS教學

以上是PHPCMS 如何加入模組?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn