Due to work, I can only give up the research on mongodb temporarily. Start researching PHPcms.
So far I have basically completed the development of the module. I will come here to make a summary during the weekend. I found that phpcms is pretty good, but there are really not many documents.
No more nonsense. For phpcms module development, you must first understand the directory structure of the module.
We can download it at http://v9.help.phpcms.cn/html/2010/structure_0928/69.html
Find its directory structure. The stuff we want to develop (that is, the module) is under /phpcms/modules/
If there is nothing special, before developing a module, you must first establish the relevant directories according to the directory structure and design the database table structure. For example, we create a module called my module my_test
The following should be the directory structure under mytest
mytest
--class //This is the class used by the mytest module
--function//Function used by mytest module
--install//Some configuration files needed to install this module and create data table myslq statements are here
--language//Will be used when using multiple languages
--config.ini.php//This configuration file is used to describe some information of the entire module
--extension.inc.php//This is to create a directory structure. This file is also used to control permissions
--model.php//What data models are used by the module. (It can be understood as which tables are used.)
--model.sql//This inserts the model record into the database
--my_test.sql//This file will be executed during installation, put the sql to create the database table
--templates //, template files used by the mytest module
--uninstall //Configuration and files used when uninstalling the module
I didn’t study the files in this. I will study them later and make up for them.
my_test.php //This is the background controller file of the mytest module`
index.php//This is the front-end controller, I didn’t write anything on this.
After establishing such a structure, we still need to establish our data model under /phpcms/model/
For example my_test_model.class.php (this uses a very typical factory pattern)
Specifically what is written in each file. Let’s look at it one by one. First, let’s look at the file we wrote under the model folder.
The second line loads the model class of the system, and the following parameter 0 means that it is not instantiated.
The last line calls the constructor of the parent class. It can be found in phpcms/libs/classes/model.class.php
And this model class defines a lot of data operation methods, the most basic addition, deletion, modification and query. I will talk about some basic methods of model in detail later.
Let’s take a look at the stuff inside modules
Let’s look at the following one by one. The first language is used to support multi-language menus.
Then there is config.ini.php, which contains some information about module installation.
The file contains this structure
Then comes extension.inc.php. This file is used to create the directory structure of the background management menu and is also used to control permissions
Then the template you use should be placed in templates. The naming rule should be mytest_add.tpl.php
The last thing is your controller. This has been researched a lot. The action in the controller is the action passed by each URL, which is the action of a=?. The default action is init