Phpcms (1) phpcms V9 MVC pattern and URL Access resolution (RPM), phpcmsmvc_php tutorial

Source: Internet
Author: User

Phpcms (1) phpcms V9 MVC mode with URL Access resolution (RPM), PHPCMSMVC


"1" URL Access resolution

Observe the URL of the Web page, you can get the module access method, the following example:

Http://www.abcd.com.cn/phpcms/index.php?m=content&c=index&a=show&id=1

The resolution for this URL is as follows:

m = content for module/model name in Phpcms/modules/content ( required )

c = Index is the controller name in phpcms/modules/content/index.php ( required )

A = Show method for event name in phpcms/modules/content/index.php

ID = 1 is the same as the normal get pass parameter for other parameters

So, here's the problem! We often visit the homepage of the URL is: http://www.abcd.com.cn/phpcms/index.php why not the value of M and C?

This explains that the system executes the default modules and operations when no modules and controllers are specified. As on the URL, the phpcms default route locates the init operation in the Content module's index controller. So the result is the same as the following URL:

Http://www.abcd.com.cn/phpcms/index.php?m=content&c=index&a=init

The system also supports the functionality of URL routing, which can bring additional URL access effects.

Its routing files are located in the phpcms\caches\configs\route.php content collation as follows:

1 
 
   Array (6  *     ' m ' = = ' Phpcms ',  7  *     ' c ' = ' index ',  8  *     ' a ' = ' init ' ,  9  * '     data ' =>array (*  '         POST ' =>array * *             ' catid ' =>112  *             ),  *         ' GET ' =>array (* '             contentid ' =>115  *             )  *         ) 17  *)  * where "M" is the model, "C" is the controller, "a" is the event, "data" is the other additional parameters.  data is a two-dimensional array that can set the default parameters for post and get.  the * post and get respectively correspond to PHP $_post and $_get two super global variables.  * In the program you can use $_post[' catid ' to get the value of the array in POST in data. The  parameter level set in the * data is relatively low. If the external program has a variable that commits the same name, the value set in the configuration file will be overwritten.  * such as: External program post a variable catid=2 then you use $_post in the program to get the value is 2, not the configuration file set in 1. The  */25 return Array (the '     Default ' =>array (' m ' + = ' content ', ' c ' = = ' index ', ' a ' = ' + ' init '), 27);

For a more specific understanding, a simple example is as follows:

1. In the Phpcms/modules directory, create a new folder named Demo, which is the module named demo

2. In the demo folder, create a new text file named Test and modify the file type to PHP. Open the test file with notepad++ and edit the contents as follows:

1 
 
  

Note: The content inside the test.php must be written in class, otherwise the control cannot be found, that is, the C in MVC cannot be found. If a is not specified, the Init method is called, and if the Init method is not implemented, it is displayed: Action does not exist.

3. In the browser's URL bar input: Http://localhost/phpcms/index.php?m=demo&c=test&a=show return results such as:

"2" module

The modules in the PHPCMS V9 framework are located in the Phpcms/modules directory, each of which is called a module. That is, m in the URL access above.

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

"3" Controller

Refer to the article "Phpcms V9 Add Module" for the Controller class

Good good Study, day.

Sequential Selection Cycle Summary

http://www.bkjia.com/PHPjc/1137259.html www.bkjia.com true http://www.bkjia.com/PHPjc/1137259.html techarticle phpcms (1) phpcms V9 MVC mode and URL Access resolution (goto), phpcmsmvc "1" URL Access resolution observe the Web page when the URL, you can get the module access method, the following example:/HTTP/ ...

  • Related Article

    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.