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!