"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 <?php 2/** 3 * Routing profile 4 * Default configuration defaults to the following: 5 * ' Default ' =>array (6 * ' m ' = ' phpcms ', 7 * ' c ' = ' index ', 8 * ' a ' = ' init ', 9 * ' data ' =>array ' POST ' =>array (one * ' catid ' =>112 * ), * ' GET ' =>array ' ContentID ' =>115 *) (*) (*) *) * where "M" is the model, "C" is the controller, "a" is the event, "data" For 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 <?php2 class Test3 {4 public function Show () 5 {6 echo "I love Phpcms V9."; 7 }8 }9?>
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
Phpcms (1) phpcms V9 MVC pattern and URL Access resolution (RPM)