In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what is the use of the PHPcms module in php, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Due to work, I have to give up the research on mongodb temporarily. Began to study PHPcms.
So far I have basically completed the development of the module. Come here on the weekend to make a summary. I found that phpcms wrote well, but there were not many documents.
Cut the crap. Module development for phpcms. First of all, we should understand the directory structure of the module.
We can do it at http://v9.help.phpcms.cn/html/2010/structure_0928/69.html.
Find his directory structure and what we're going to develop (that is, modules) is under / phpcms/modules/.
If nothing special, before developing a module, we should first set up the relevant directory according to the directory structure and design the database table structure, for example, let's build a module called my module my_test.
The following should be the directory structure under mytest
Mytest
-- class / / this is the class that the mytest module will use
-- functions used by the function//mytest module
-- install// some configuration files and myslq statements needed to install this module are here.
Language// is used when it is multilingual.
-- config.ini.php// this configuration file is used to describe some information of the whole module
-- extention.inc.php// this is to create a directory structure. This file is also used to control permissions.
Which data models are used by the model.php// module. It can be understood as which tables are used.
-- model.sql//, the record that inserts the model into the database
The my_test.sql// file will be executed during installation, putting in the sql that creates the database table
-- templates / /, the template file used by the mytest module
-- uninstall / / configuration and files used to uninstall the module
I didn't study the documents in this. I went back to study and made up.
My_test.php / / this is the background controller file of the mytest module.`
Index.php//, this is the front desk controller. I didn't write anything about this.
After building such a structure, we also need to build our data model under / phpcms/model/.
For example, my_test_model.class.php (this uses a typical factory pattern)
What exactly is written in each file? Let's look at it one by one. First, let's take a look at the file we wrote under the model folder.
The copy code is as follows:
The function of the first line is to determine whether it is within the running framework of phpcms.
The second line loads the model class of the system, and the parameter 0 means that it is not instantiated.
The last line calls the constructor of the parent class. Can be found in phpcms/libs/classes/model.class.php
This model class defines many of the most basic additions, deletions, modifications and queries for the operation of data. I'll talk more about some of the basic methods of model later.
Next, let's take a look at the contents of modules.
One by one, we looked down at the first language to support multilingual menus.
Then there is config.ini.php, which contains some information about module installation.
This is the structure in the file.
The copy code is as follows:
$module = 'model used by mytest';//
$modulename = 'here is the name of the module'
$introduce = 'module description information'
$author = 'author'
$authorsite = 'author's website'
$authoremail = 'author email'
It's clearly marked inside.
Then there is extention.inc.php, which is used to create the directory structure of the background management menu, as well as to control permissions.
The copy code is as follows:
$id= $menu_db- > insert (array ('name'= >' here is the name of the operation, 'parentid'= > parent ID,' masking = > 'module', 'controller', 'data'= = >', 'listorder'= > sort,' display'= > 'display'), true); / / the last true is used to return ID
There should be an array at the end of the file, which is used to insert the system's\ language\ zh-cn\ system_menu.lang.php in the following format
The copy code is as follows:
$language = array (
"here is the name of the operation you came up with" > "here is the Chinese translation of the operation"
Similar to: 'mytest_init'= >' display list'
);
And then there's model.php, which is what data models you use, which tables are used.
The copy code is as follows:
Return array ('mytest','my_test_artcle')
Then there is model.sql, which is used to insert data into the model table of the system.
The copy code is as follows:
INSERT INTO `module` (`module`, `name`, `url`, `iscore`, `version`, `accountion`, `setting`, `listorder`, `modulled`, `installdate`, `update`) VALUES ()
Then mytest.sql 's statement to create your database table should be written in this file.
And then the template you use should be placed in templates, and the naming rule should be mytest_add.tpl.php.
Finally, there is some research on your controller. In the controller is the action passed by each of your url, that is, axiom? The action of. The default action is init
The copy code is as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.