As mentioned above, ThinkPHP builds the first project and creates the first module application. The following describes how ThinkPHP calls the template.
As mentioned above, ThinkPHP builds the first project and creates the first module application. The following describes how ThinkPHP calls the template.
Combined with the MVC view, we know that the module application is our controller (C), and the next step is to call the corresponding template. The default ThinkPHP template is placed in Tpl/default under the project folder. if necessary, we can create other template folders.
The template corresponding to the console's internal operations (for example, index.html, and checklogin.html. For example:
// Inherit the Action class first. note: the file name must be consistent with the class name.
Class UserAction extends Action
{
// The default action (Operation and method) loaded in each module is the index method.
Function index ()
{
// By default, the Tpl/default/userfolder and the template file (index.html) with the same name (index.html) are found)
$ This-> display ();
}
Function checkLogin ()
{
// When only the name of the template file is written, thinkphp will automatically find checklogin.html
$ This-> display (checkLogin );
}
// The naming rule for methods (operations and actions) is: the first letter followed by the first letter in lowercase
Function listName ()
{
// Force the conversion template. it is not necessary to display the template file with the same name as the current operation. for example, you need to use the edit.html template.
$ This-> display (edit );
}
}
?>