PHPCMS Two Development Tutorials (RPM), phpcms Two development Tutorials _php Tutorials

Source: Internet
Author: User
Tags php database

PHPCMS Two Development Tutorials (RPM), phpcms Two-time development tutorials


Transferred from: http://www.cnblogs.com/semcoding/p/3347600.html

Structural design of Phpcms V9

root directory
|–API Structure file directory
|–caches Cache file Directory
|–configs System Configuration file directory
|–caches_* System Cache Directory
|–PHPCMS PHPCMS Framework Home Directory
|–languages Framework Language Pack Directory
|–libs Framework main class library, main function library directory
|–model Framework Database Model Catalog
|–modules Framework Module Catalog
|–templates Framework System Template Catalog
|–phpsso_server Phpsso Home Directory
|–statics System Accessory Kit
| –CSS System CSS Package
| –images System Picture Package
| –js System JS Package
|–index.php Program main Entrance

Phpcms V9 Core File description

Modules and controllers

Module:

The modules in the PHPCMS v9 Framework, located in the Phpcms/modules directory, are referred to as a module in each directory. That is, m in URL access.

Example of accessing the content module: http://www.yourname.com/index.php?m=content

Controller:

The controller of the Phpcms V9 is the class file of the module, located under the phpcms/modules/module/directory. The class name achievement is the file name +.php, such as a controller named ABC, then his name is abc.php. The controller class inherits the system's library of functions by default and can be used directly. The class name of the controller class must be the same as the controller filename. If you create a abc.php under the test module, then we enter URL:HTTP://WWW.YOURNAME.COM/INDEX.PHP?M=TEST&C=ABC in the browser

Two-time development tips

If you want to develop the existing controller two times, in order to facilitate the upgrade is not recommended directly to the kernel files directly modified, you can be "my_*.php" in the form of two development.

For example, you need to develop two times to change phpcms/mood/index.php. You can create "my_index.php" in a directory similar to index.php

 

This way, when you access the index controller through a URL, the system will default to my_index.php and the original file method will be inherited and can be used directly.

System configuration File

File path: root directory/caches/configs

    • database.php Database configuration file
    • system.php System Configuration File
    • route.php Routing configuration file

Calling methods

If you call Web_path in the system configuration:

Pc_base::load_config (' System ', Web_path ');

CMS Entry file:

PHPCMS is developed using the MVC design pattern, accessed in a modular and operational manner, with a single entry mode for project deployment and access, regardless of access to any module or function, with only one unified portal.

The ingress program is the bootloader that processes the user request in the pre-process. It is the only one that can be run directly by the end user.

File path: root directory/index.php

 
   

This code first loads the boot file base.php of the PHPCMS framework, and then it builds a WEB application instance and runs according to the specified configuration file.

Phpcms Framework Entry file:

File path: The root directory/phpcms/base.php code snippet is as follows:

 
   

The file is a framework entry file, which includes instantiating system/module class methods, invoking System/module methods, System constants, and so on. Such as:

Pc_base::load_model (' *_model ') loads the database model Pc_base::load_sys_class (' classname ') instantiation of the System class Pc_base::load_app_class (' ClassName ', ' admin ') Instantiate module class Pc_base::load_sys_func (' Funcfile ') call system function library

Global function File:

File path: The root directory/phpcms/libs/functions/global.func.php code snippet is as follows:

 
   $val) $string [$key] = new_addslashes ($val); return $string;} ......? >

The function in this file, which is a system-wide basic function, can be called directly in the system.

Two-time development tips:

If you need to add your own global functions, you can add them to/phpcms/libs/functions/global.func.php/extention.func.php as needed without affecting the upgrade

Data Model base class:

File path: The root directory/phpcms/libs/classes/model.class.php code snippet is as follows:

 
   

After the data model is loaded, you can perform database operations on the methods in that class of the database.

Table Monotone class:

File path: root directory/phpcms/libs/classes/form.class.php. The code snippet is as follows:

 
   

By instantiating the class, you invoke a form called the editor, form upload, date selection, column structure, and so on in the program. Instantiation method: Pc_base::load_sys_class (' form ', ', 0);

Template parsing Cache class:

File path: root directory/phpcms/libs/classes/template_cache.class.php. The code snippet is as follows:

 
   

This class functions as parsing templates, parsing templates, and updating template caches

Phpcms V9 two times development

Phpcms URL Access:

PHPCMS is developed using the MVC design pattern, accessed in a modular and operational manner, with a single entry mode for project deployment and access, regardless of access to any module or function, with only one unified portal.

Parameter Name Description Location remarks

    • M model/Module name phpcms/modules The module directory name must be
    • C controller name phpcms/modules/module/*.php file name must be
    • A Event name phpcms/modules/the method name in module/*.php

Module access Methods [Example]:

Two-time development naming conventions

class files need to be suffixed with. class.php (here refers to the PHPCMS system class library files and class library files in the module, the third party introduces no requirements), such as http.class.php.

The function file needs to be suffixed with. func.php (third-party-introduced non-requirements), such as mail.func.php.

The class name and file name are identical, for example the file name of the Phpcmsapp class is phpcmsapp.class.php.

The data model needs to be in the form of "data table name _model.class.php" and the class name must be the same as the file name.

Two development and development processes

To create a database model class

The database model is located in the: phpcms/model/directory.

Naming rules for data model files recommended for data table name + ' _model.class.php '

If in our created module I want to use a database "test", first need to establish a database model file, the file name is called ' test_model.class.php '

 
   Db_config = pc_base::load_config (' database ');     $this->db_setting = ' default ';    $this->table_name = ' Test ';  Parent::__construct (); }}?>

The database model class name must be the same as the file name;

$this->db_setting = ' default ' configures the database link pool name in the database configuration file, defaults to default and generally does not need to be modified. $this->table_name = ' test ' for the data table name

Create a module

If you want to create a module, simply create a folder in the Phpcms/modules directory and put it in your controller class.

For example, to develop a module called test, first create a folder under the Phpcms/modules directory and name it test. The standard structure of the module is usually the case.

If your template has a separate foreground template, you need to create a directory of your modules under Phpcms/templates/default to place the foreground template, "default" is your style package name, we default

Example of accessing the test module: http://www.yourname.com/index.php?m=test

Creating a Module Controller class

Add a controller file path named Myest to the test module: root directory/phpcms/modules/test/mytest.php. The code snippet is as follows:

 
   

List of common operations (1)

1. Invoking the Database model

$this->db = Pc_base::load_model (' Test_model ');

The methods supported in $this->db refer to the methods in phpcms/libs/classes/model.class.php

2. Loading System Classes

$http = Pc_base::load_sys_class (' http '); Instantiate the HTTP Class pc_base::load_sys_class (' format ', ', 0); Calling the form class without instantiating the operation 3. Loading system Letters

3. Loading the system function library

Pc_base::load_sys_func (' Mail '); Calling the Mail function package

4. Loading module classes

$test = Pc_base::load_sys_class (' classname ', ' test '); Instantiate the ClassName class under test module

5. Load Module Function library

Pc_base::load_sys_func (' Global ', ' test '); Calling the test module's global function package

List of common operations (2)

6. Loading the foreground template

Include template (' Test ', ' mytest ', ' Default ');

7. Loading the background template

Include $this->admin_tpl (' mytest_admin_list ');

8. Permission Control

The background control controller needs to load the Admin class under the admin module and inherit the class

 
   

http://www.bkjia.com/PHPjc/1137778.html www.bkjia.com true http://www.bkjia.com/PHPjc/1137778.html techarticle Phpcms Two Development Tutorials (RPM), phpcms Two development tutorials from: http://www.cnblogs.com/semcoding/p/3347600.html PHPCMS V9 structure Design root directory |–api structure file directory |– ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.