Thinkphp template usage problems

Source: Internet
Author: User
Thinkphp template usage problems in thinkphp combined with the smarty template, all have been configured, in IndexAction. class. $ this-& gt; display (& quot; login & quot;) is used in the PHP file, but DefaultAction is another file. class. if the php file is also used, the thinkphp template usage problem occurs.
The smarty template has been configured in thinkphp. class. $ this-> display ("login") is used in the PHP file, but the DefaultAction is another file. class. if PHP files are used in the same way, the following problems may occur:
Fatal error: Call to a member function display () on a non-object in E: \ php \ AppServ \ www \ DLP \ ThinkPHP \ Lib \ Think \ Core \ Action. class. php on line 103

The code for Action. class. php is:

Protected function display ($ templateFile = '', $ charset ='', $ contentType = 'text/html ')
{Echo $ templateFile;
If (false ===$ templateFile ){
$ This-> showTrace ();
} Else {
$ This-> view-> display ($ templateFile, $ charset, $ contentType );
}
}

Have you ever had the same problem? give me some help...

------ Solution --------------------
I have also seen it, because Action uses the constructor.
Function _ construct ()
{
// Content
}

Use in TP

Function _ construct ()
{
Parent: :__ construct;
}

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.