ThinkPHP first call Template

Source: Internet
Author: User
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 );

}
}

?>
 

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.