Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty errorl unable to read template resource
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
Smarty Pants
Smarty Rookie


Joined: 29 Apr 2003
Posts: 7
Location: Winnipeg, Manitoba

PostPosted: Tue Apr 29, 2003 6:07 pm    Post subject: Smarty errorl unable to read template resource Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Apr 29, 2003 6:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Apr 29, 2003 6:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Smarty Pants
Smarty Rookie


Joined: 29 Apr 2003
Posts: 7
Location: Winnipeg, Manitoba

PostPosted: Tue Apr 29, 2003 8:04 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Apr 29, 2003 9:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Smarty Pants
Smarty Rookie


Joined: 29 Apr 2003
Posts: 7
Location: Winnipeg, Manitoba

PostPosted: Tue Apr 29, 2003 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Sri_Lumpa
Smarty Rookie


Joined: 24 Apr 2003
Posts: 8
Location: Paris, FRANCE

PostPosted: Wed Apr 30, 2003 9:15 am    Post subject: Reply with quote

You wrote $smarty->complir_dir
instead of $smarty->compile_dir Wink
Back to top
View user's profile Send private message
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Sat Jul 19, 2003 11:50 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Sat Jul 19, 2003 12:06 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Jul 19, 2003 12:38 pm    Post subject: Reply with quote

this
Quote:
problem writing temporary file '//3f1933b4c833b'
normally means you didn't configure your compile_dir correctly.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Sat Jul 19, 2003 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Jul 19, 2003 3:17 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Sat Jul 19, 2003 9:01 pm    Post subject: Reply with quote

Unfortunately, removing the trailing slashes didn't do anything. Sad

(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
View user's profile Send private message Visit poster's website AIM Address
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Jul 19, 2003 9:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Sat Jul 19, 2003 9:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP