Home > CMS Tutorial > PHPCMS > How to add modules to PHPCMS?

How to add modules to PHPCMS?

Guanhui
Release: 2020-06-18 17:01:04
Original
2989 people have browsed it

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;

How to add modules to PHPCMS?

  • 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(&#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;
        }
    }
?>
Copy after login

Then load the front-end template and back-end template;

public function init()
{
    $myvar = &#39;hello world!&#39;;
    echo $myvar;
    include template(&#39;test&#39;, &#39;index&#39;);
}
Copy after login
public function init()
{
    $myvar = &#39;oh,i am phpcmser&#39;;
    echo $myvar;
    include $this->admin_tpl(&#39;mytest_admin_list&#39;);
}
Copy after login

Finally create the database model class.

<?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();
    }
 }
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template