The template and Operation ing function is a ing mechanism for module and Operation settings supported by version 3.1.2. because the URL access address can be dynamically changed by changing the configuration (actually changed, not the alias, the security of the application is enhanced, and the ing mechanism has the URL case-insensitive access feature, which is also very helpful for application migration. The template and Operation ing function is a ing mechanism for module and Operation settings supported by version 3.1.2. because the URL access address can be dynamically changed by changing the configuration (actually changed, not the alias, the security of the application is enhanced, and the ing mechanism has the URL case-insensitive access feature, which is also very helpful for application migration.
Under normal circumstances, if you need to change the URL module or operation access, there are many files to be modified, which may easily lead to association errors. In particular, when many applications need to migrate to the new version, the URL address is greatly adjusted due to many changes to the model and controller. through the module and Operation ing function, it can easily solve such problems.
To define module ing, you only need to define it in the configuration file:
- 'URL _ MODULE_MAP '=> array (
- 'User' => 'Member ',
- 'Blog '=> 'info ',
- )
The copy code URL_MODULE_MAP is an array. each array item represents:
- 'Module ing name' => 'actual module name'
The copy code ing name is case-insensitive. Therefore, after setting the ing name, the URL access starts from the original:
- Http: // serverName/index. php/Member/index
- Http: // serverName/index. php/Info/index
The copied code is changed:
- Http: // serverName/index. php/user/index
- Http: // serverName/index. php/blog/index
Copy the code and the original access URL is invalid. this is also one of the differences between changing the URL and defining the routing mode. The access to modules without a ing definition remains unchanged.
After the module ING is defined, you can use
MODULE_ALIASConstant reads the URL name of the current module.
Operation ing not only supports module name ing, but also supports ing of Operation names. operation ING is defined as follows:
- 'URL _ ACTION_MAP '=> array (
- 'Member' => array (
- 'Register '=> 'Add ',
- ),
- 'Info' => array (
- 'List' => 'index'
- ),
- )
The copy code URL_ACTION_MAP parameter is a two-dimensional array. each array item represents:
- 'Actual module name' => array (
- 'Operation ing name 1' => 'actual operation name 1'
- 'Operation ing name 2' => 'actual operation name 2'
- ......
- )
The copy code operation ing name is case insensitive.
- Http: // serverName/index. php/Member/add
- Http: // serverName/index. php/Info/index
The copied code is changed to (regardless of the previously defined module Ing ):
- Http: // serverName/index. php/Member/register
- Http: // serverName/index. php/Info/list
Copy the code, and access from the original URL fails. The operation access address that does not define the ING remains unchanged.
After the operation ING is defined, you can use
ACTION_ALIASConstant reads the name of the operation in the URL of the current operation.
Operation ING and module ING can be defined at the same time without any impact, for example:
- 'URL _ MODULE_MAP '=> array (
- 'User' => 'Member ',
- ),
- 'URL _ ACTION_MAP '=> array (
- 'Member' => array (
- 'Register888' => 'Add ',
- ),
- )
Copy the code, the original registration address
- Http: // serverName/index. php/Member/add
The copied code becomes
- Http: // serverName/index. php/user/register888
Copy code
Many people may worry about the automatic support of the U function. after setting the module and Operation ING, the U function will need to be changed accordingly. In fact, you don't need to worry about it because the U function automatically supports module and Operation ING.
For example
- Href = "{: U ('Member/add')}"> user registration
No matter how you define the ing between the Member module and the add operation, the write method of the U method remains unchanged and still points to the mapped URL address correctly.
The summary module and Operation ING can be used in the following scenarios:
1. frequent URL changes
2. high URL security
3. applications to be transplanted do not want to change the URL address.
Precautions:
After the module and Operation ing are used, the routing definition of the relevant URL address may need to be adjusted.