Please help when using the smarty template with Warning: Smartyerror: unabletoreadresource:

Source: Internet
Author: User
Please help when using the smarty Template: Warning: Smartyerror: unabletoreadresource: Template directory: I checked it with $ tpl-> template_dir. The Template directory is correct. Why can't it be displayed? please help me
Error message: Warning: Smarty error: unable to read resource: "admin" in D: \ AppServ \ www \ moban \ libs \ Smarty. class. php on line 1095
The following are the initialized programs.

Define (ROOT, "C:/AppServ/www/xsphp /");
Include ROOT. "libs/Smarty. class. php ";

$ Tpl = new Smarty;
$ Tpl-> template_dir = ROOT. "tpl /";
$ Tpl-> compile_dir = ROOT. "com ";
$ Tpl-> left_delimiter = "<{";
$ Tpl-> right_delimiter = "}> ";
Main program: Require "init. inc. php ";

$ Title = "this is a title ";

$ Content = "this is body content ";

$ Tpl-> assign ("title", $ title );
$ Tpl-> assign ("content", $ content );

$ Tpl-> display ("default/test. tpl ");


Reply to discussion (solution)

I didn't see your display admin code? Is the code fully pasted?

Add the code of the main program. I have posted an error. it should be the following:
Require "init. inc. php ";
$ Title = "this is a title ";
$ Content = "this is a content ";
$ Tpl-> assign ("title", $ title );
$ Tpl-> assign ("content", $ content );
$ Tpl-> display ("admin ");
Echo $ tpl-> template_dir;
The following is the program in the admin template:

<{$ Title}>

<{$ Content}>





I didn't see your display admin code? Is the code fully pasted?

I added it. let me see it again. I still haven't found any errors.

$ Tpl-> display ("default/test. tpl ");


The default/test. tpl file is not created.

$ Tpl-> display ("default/test. tpl ");


The default/test. tpl file is not created.

Created. the above post is incorrect. I posted the correct post in the comment. it should be $ tpl-> display ("admin"). I created an ammin template.

Have you specified that your tpl template file is under/moban/tpl?

$ Tpl-> display ("admin"); this error

Define (ROOT, "C:/AppServ/www/xsphp /");
Include ROOT. "libs/Smarty. class. php ";

$ Tpl = new Smarty;
$ Tpl-> template_dir = ROOT. "tpl /";
$ Tpl-> compile_dir = ROOT. "com ";

The path you set here is inconsistent with the path of your image template file

Then
$ Tpl-> display ("admin. tpl ");

Then
$ Tpl-> display ("admin. tpl ");



You have added a suffix. thank you!

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.