View previous topic :: View next topic |
Author |
Message |
Smarty Pants Smarty Rookie
Joined: 29 Apr 2003 Posts: 7 Location: Winnipeg, Manitoba
|
Posted: Tue Apr 29, 2003 6:07 pm Post subject: Smarty errorl unable to read template resource |
|
|
Using the documentation I installed Smarty-2.5.0. I then created an instance of Smarty, assigned a template variable and tried to display the index.tpl file. I loaded the index.php file from my web browser and got the following error:
Warning: Smarty error: unable to read template resource: "index.tpl" in /usr/local/lib/php/Smarty/libs/Smarty.class.php on line 1042
I've checked the absolute paths, file ownership and permissions and I can't seem to find out what's wrong. The following is the code I'm using:
/home/web/seventicks/calendar/index.php looks like this:
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = '/home/web/seventicks/smarty/calendar/templates/';
$smarty->complir_dir = '/home/web/seventicks/smarty/calendar/templates_c/';
$smarty->config_dir = '/home/web/seventicks/smarty/calendar/configs/';
$smarty->cache_dir = '/home/web/seventicks/smarty/calendar/cache/';
$smarty->assign('name','Kelly');
$smarty->display('index.tpl');
___________________________________________________
/home/web/seventicks/smarty/calendar/index.tpl:
{* Smarty *}
Hello, {$name}!
______________________________________________
I'm new to Smarty so perhaps I've overlooked something. Any suggestions as to why I'm getting this error would be greatly appreciated.
Thanks _________________ 'we are the music makers, we are the dreamers of dreams" -Charlie and the chocolate factory |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Apr 29, 2003 6:54 pm Post subject: |
|
|
put it in the "templates"-dir . smarty looks for it in /home/web/seventicks/smarty/calendar/templates/ as you told it to.
HTH
(and you have a typo in "$smarty->compile_dir = ...") |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Apr 29, 2003 6:58 pm Post subject: |
|
|
If you are getting that error, either you don't have the template stored in the $smarty->template_dir OR you are on a windows box (though it looks like you are *nix) which means you need to include the drive letter:
'C:/home/web/seventicks/smarty/calendar/templates/' |
|
Back to top |
|
Smarty Pants Smarty Rookie
Joined: 29 Apr 2003 Posts: 7 Location: Winnipeg, Manitoba
|
Posted: Tue Apr 29, 2003 8:04 pm Post subject: |
|
|
Thanks for the quick reply!
I fixed the typo and
my index.tpl file is in /home/web/seventicks/smarty/calendar/templates/
and yes I am running Smarty on a Linux box.
I tried going down to a previous version, Smarty-2.4.2 to see if that would solve my problems, but no luck.
I'm still getting the same error. _________________ 'we are the music makers, we are the dreamers of dreams" -Charlie and the chocolate factory |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Apr 29, 2003 9:44 pm Post subject: |
|
|
Messju is so good at picking out those hard to find errors!!
You wrote that:
Code: | /home/web/seventicks/smarty/calendar/index.tpl:
{* Smarty *}
Hello, {$name}! |
But as Messju pointed out, it needs be in /home/web/seventicks/smarty/calendar/templates/index.tpl in your case.
Otherwise, I'm at a bit of a loss--the example is straight from the manual, so we know it should work! I'm reaching--are there any funky (non-default) settings in your PHP.ini??[/code] |
|
Back to top |
|
Smarty Pants Smarty Rookie
Joined: 29 Apr 2003 Posts: 7 Location: Winnipeg, Manitoba
|
Posted: Tue Apr 29, 2003 10:00 pm Post subject: |
|
|
The php.ini file is pretty straight forward... nothing funky that I know about.
I changed the following code in index.php:
$smarty->display('index.tpl');'
to
$smarty->display('/home/web/seventicks/smarty/calendar/templates/index.tpl');
and now everything works.
Any idea why? _________________ 'we are the music makers, we are the dreamers of dreams" -Charlie and the chocolate factory |
|
Back to top |
|
Sri_Lumpa Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Paris, FRANCE
|
Posted: Wed Apr 30, 2003 9:15 am Post subject: |
|
|
You wrote $smarty->complir_dir
instead of $smarty->compile_dir |
|
Back to top |
|
Häakon Smarty Rookie
Joined: 19 Jul 2003 Posts: 18 Location: San Diego, California
|
Posted: Sat Jul 19, 2003 11:50 am Post subject: |
|
|
I'm a new Smarty user, and I did use the search function to try to find an answer to my problem (that's why I'm posting in this topic and not a new one), but unfortunately I'm having the exact same problem that "Smarty Pants" is having, except I didn't spell anything incorrectly. All of my paths are set correctly, and I'm using the identical examples used in the setup guide (it still says "$smarty->assign('name','Ned');", even), and i get the same error
Code: | Warning: Smarty error: unable to read template resource: "index.tpl" in /home/virtual/site122/fst/var/www/html/require/Smarty/Smarty.class.php on line 1042 |
I have not yet tried switching
$smarty->display('index.tpl');'
to
$smarty->display('/home/showchoir/smarty/schools/templates/index.tpl');
(my path), but even if that works, I don't want to mess something up down the road because something is not configured correctly. If it makes any difference, I've already assigned $use_sub_dirs to FALSE (I've noticed that's a common problem around here), and haven't gone any further than this initial setup procedure. Is there anything I can do to remedy this situation? |
|
Back to top |
|
Häakon Smarty Rookie
Joined: 19 Jul 2003 Posts: 18 Location: San Diego, California
|
Posted: Sat Jul 19, 2003 12:06 pm Post subject: |
|
|
As an aside, I further went ahead and included the literal path just to make sure it would work - and even that spits out errors. Doing that gives me this in return:
Code: | Warning: Smarty error: problem writing temporary file '//3f1933b4c833b' in /home/virtual/site122/fst/var/www/html/require/Smarty/Smarty.class.php on line 1042
Warning: unable to create file /^home^showchoir^smarty^schools^templates^index.tpl because Permission denied in /home/virtual/site122/fst/var/www/html/require/Smarty/Smarty.class.php on line 1575
Warning: Unable to access /^home^showchoir^smarty^schools^templates^index.tpl in /home/virtual/site122/fst/var/www/html/require/Smarty/Smarty.class.php on line 1158
Warning: Failed opening '/^home^showchoir^smarty^schools^templates^index.tpl' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site122/fst/var/www/html/require/Smarty/Smarty.class.php on line 1158 |
That looks like a lot of permission errors to me, but I'm not sure what I'm supposed to have given permissions to. I chmod'ed the templates_c and cache directory to 775 like the instructions said... |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jul 19, 2003 12:38 pm Post subject: |
|
|
this Quote: | problem writing temporary file '//3f1933b4c833b' | normally means you didn't configure your compile_dir correctly. |
|
Back to top |
|
Häakon Smarty Rookie
Joined: 19 Jul 2003 Posts: 18 Location: San Diego, California
|
Posted: Sat Jul 19, 2003 1:11 pm Post subject: |
|
|
Where do you "configure" that? I have the path listed in my index.php as
$smarty->compile_dir = '/home/showchoir/smarty/schools/templates_c/';
is that what you mean? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jul 19, 2003 3:17 pm Post subject: |
|
|
yep, but without the trailing slash. only SMARTY_DIR needs a trailing-slash, but no other dir that smarty uses should have one. |
|
Back to top |
|
Häakon Smarty Rookie
Joined: 19 Jul 2003 Posts: 18 Location: San Diego, California
|
Posted: Sat Jul 19, 2003 9:01 pm Post subject: |
|
|
Unfortunately, removing the trailing slashes didn't do anything.
(Just to let you know, they include trailing slashes in the install documentation when they tell you how to set up your index.php, but I digress...)
Any other thoughts? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Jul 19, 2003 9:11 pm Post subject: |
|
|
Häakon, has it occured to you to post your code sample as well as the versions of Smarty, PHP and OS you are using?
If you read the forums, you will notice that A LOT OF PEOPLE have this problem and in all but one case, it was because they misconfigured.
We WILL help you if you show us what you have done and what that results in.
Good Luck! |
|
Back to top |
|
Häakon Smarty Rookie
Joined: 19 Jul 2003 Posts: 18 Location: San Diego, California
|
Posted: Sat Jul 19, 2003 9:29 pm Post subject: |
|
|
Sure, no problem at all. Here's my index.php code:
Code: | <html>
<head>
<title></title>
</head>
<body>
<?php
// load Smarty library
require('../require/Smarty/Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = '/home/showchoir/smarty/schools/templates';
$smarty->compile_dir = '/home/showchoir/smarty/schools/templates_c';
$smarty->config_dir = '/home/showchoir/smarty/schools/configs';
$smarty->cache_dir = '/home/showchoir/smarty/schools/cache';
$smarty->assign('name','Ned');
$smarty->display('/home/showchoir/smarty/schools/templates/index.tpl');
?>
</body>
</html> |
And here's the code for the index.tpl, which resides in the "templates" directory:
Code: |
{* Smarty *}
Hello, {$name}! |
PHP Version is 4.0.6 and it's running on linux. I have tried putting the special folders (templates, templates_c, configs, and cache) below the web root like it recommends, but also tried putting them as accessible to the web since that wasn't working. Both methods are giving me the exact same results. Thank you in advance for your help, I do appreciate it. |
|
Back to top |
|
|