RE: [SMARTY] Smarty error: unable to read template resource
| From: | Wayne Walker | Date: | Sat, 09 Nov 2002 06:05:31 +0000 |
| Subject: | RE: [SMARTY] Smarty error: unable to read template resource | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6372@lists.php.net to get a copy of this message | ||
Hi Diarmid,
I didn't think I'd be responding to anything in this list for some time. I
am way too inexperienced with Smarty, as I have only just in the last few
weeks started to read up on all I could, having decided after a lot of
research that this is the best Templating structure around (for my needs),
in conjunction with PHPAccelerator. I do enjoy reading the technical posting
on this list, though.
Anyway, even though I am green when it comes to Smarty, I have had a lot of
experience across Unix and MS Windows environments. Therefore, last weekend
when I experienced problems installing Smarty on my Win2000 Server at home
(it's my wife's machine, so what can I say), I used some of the previous
"pull your hair out" experience I've had with installing Unix origin
software under Windows and managed to get the examples going. Haven't had
the chance to do anything else since, but there's always this weekend.
Anyway, I can't remember everything I did to make the thing work, but I do
remember that it took a bit of trial and error. So perhaps the best thing
for me to do is list my settings. Then maybe you could give them a go. Here
goes:
To save me trouble in setting up PHP / MySQL / Apache under Windows, I used
a free Australian based installation process produced by a company called
Firepages (www.firepages.com.au), which is easy to use and seems to work
well. That process installs everything under a directory "C:\phpdev\". From
there, the files structure I used is as follows:
File Structure:
Web Document Directory: c:\phpdev\www\
Includes Directory: c:\phpdev\includes\
Smarty Example Directory: c:\phpdev\www\guestbook\
Template Directories: c:\phpdev\smarty\guestbook\cache
c:\phpdev\smarty\guestbook\config
c:\phpdev\smarty\guestbook\templates
c:\phpdev\smarty\guestbook\templates_c
For the "Basic Installation", my index.php file content was as follows:
<?php
define(SMARTY_DIR,'c:/phpdev/includes/');
require(SMARTY_DIR.'Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'c:/phpdev/smarty/guestbook/templates/';
$smarty->compile_dir = 'c:/phpdev/smarty/guestbook/templates_c/';
$smarty->config_dir = 'c:/phpdev/smarty/guestbook/config/';
$smarty->cache_dir = 'c:/phpdev/smarty/guestbook/cache/';
$smarty->assign('name','Ned');
$smarty->display('index.tpl');
?>
For the "Extended Setup", my index.php file content was:
<?php
// Get the Class information from the setup file.
require("c:/phpdev/includes/setup.php");
// Instantiate a new instance of the class the use it.
$smarty = new Smarty_GuestBook;
$smarty->assign("name","Ned");
$smarty->display("index.tpl");
?>
... and the setup.php file content (under the c:\phpdev\includes\
directory), was:
<?php
// Load Smarty library files.
define(SMARTY_DIR,'c:/phpdev/includes/');
require(SMARTY_DIR.'Smarty.class.php');
// A good place to load application library files, example:
// require('guestbook/guestbook.lib.php');
class Smarty_GuestBook extends Smarty
{
function Smarty_GuestBook()
{
// Class Constructor. These automatically get set with each new instance.
$this->template_dir = 'c:/phpdev/smarty/guestbook/templates/';
$this->compile_dir = 'c:/phpdev/smarty/guestbook/templates_c/';
$this->config_dir = 'c:/phpdev/smarty/guestbook/configs/';
$this->cache_dir = 'c:/phpdev/smarty/guestbook/cache/';
// Set caching to work and define application name.
$this->caching = true;
$this->assign("app_name","Guest Book");
}
}
?>
This all seems to be working fine, as far as I can see.
I know the directory character I used is the Unix rather than Windows
syntax, but I understand that Windows is supposed to be flexible in
interpreting that. Anyway, for my set up, that seems to work fine.
Over the next few weeks, I hope to be doing a lot more with this, but in the
meantime, I do have a version running fine on a Windows 2000 platform. Then
for the real work after the development is done, I will move it to where it
will probably feel more at home in a Unix environment.
Hope this is of some help to you. Don't hesitate to drop me a line if you
need clarification on any of this.
Cheers,
Wayne
-----Original Message-----
From: Diarmid Sloan [mailto:dsloan@kpoint.co.uk]
Sent: Friday, November 08, 2002 12:59 AM
To: smarty-general@lists.php.net
Subject: [SMARTY] Smarty error: unable to read template resource
Hi,
I am trying to install Smarty on Windows 2000 Professional. I already have
a working Apache and PHP installation. However, when attempting to code my
own Smarty example or even use the existing example I keep getting the
following error:
Smarty error: unable to read template resource: "index.tpl" in
C:/apache/php/pear/Smarty/Smarty.class.php
on line 589
I have viewed loads of postings on this problem in various newsgroups but
they all make "suggestions" and no-one seems to indicate whether these
work or not. I have tried all of them but to no avail.
I have installed the Smarty directory under C:/apache/php/pear and added
C:\apache\php\pear\Smarty into the PHP include_path. However, judging by
the error the Smarty.class.php is being found ok so that isn't the problem.
My example is called test.php and lives in C:/apache/htdocs/SmartyExample
with the template index.tpl in the templates subdirectory.
The web browser can see the template ok, it's just that the class
seemingly can't. Most of the advice on newsgroups centres around checking
directory permissions on the templates directory and the templates_c
directory that I created. However, in Windows I have checked these and
they are read/write/executable. Is there more than meets the eye to
setting permissions on Windows directories? I thought these would be
read/write/executable by default. In the folder properties they are
accessible by "Everyone".
I have also tried defining the template (and other) directories within the
constructor of my extended Smarty class. I have tried using the absolute
path, ie. "file:C:/apache/htdocs/SmartyExample/templates/", defining the
path relative to the web server document root, ie.
"/SmartyExample/templates/" (with and without the trailing slash) and the
error just won't go away.
Any suggestions before I tear all my hair out!
Thanks,
Diarmid Sloan
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php