Re: [SMARTY] Smarty unable to read template resource?
| From: | Jon Bertsch | Date: | Mon, 13 Jan 2003 21:23:38 +0000 |
| Subject: | Re: [SMARTY] Smarty unable to read template resource? | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7147@lists.php.net to get a copy of this message | ||
I have a number of different apps and sites that use smarty all residing on one server. To avoid having multiple copies of Smarty I reference the one smarty Directory and store template files in sub-directories for each website.
To reference the one copy of smarty add this to your PHP file.
//Call templates and define location of engine
define("SMARTY_DIR", "/path_to_smarty_directory/smarty/");
require_once(SMARTY_DIR."Smarty.class.php");
Then within the smarty.class.php around line 63:
// public vars
var $template_dir = '/path_to smarty_templates_directory/templates'; // name of directory for templates
var $compile_dir = '/path_to_smarty_compile_directory/templates_c'; // name of directory for compiled templates
Make sure templates_c is owned by the same user as the webserver (often apache:apache or nobody:nobody).
Within your php file call the Smarty class files and in the display directive:
$smarty->display("my_sub_directory_below_templates/my_template.tpl");
You can set up the compile directory and template directory anywhere that you want to although under the smarty directory is the obvious place to do this:
Here's a possible setup:
/usr/local/apache/
- smarty
- configs
- templates_c
-templates
-sub_one
-sub_two
Then your call in the php file would be:
define("SMARTY_DIR", "/usr/local/apache/smarty/");
require_once(SMARTY_DIR."Smarty.class.php");
and
var $template_dir = '/usr/local/apache/smarty/templates'; // name of directory for templates
var $compile_dir = '/usr/local/apache/smarty/configs/templates_c'; // name of directory for compiled templates
I hope this is of some use to you in getting Smarty up and running.
Jon bertsch
On Mon, 2003-01-13 at 13:23, Brian Fidler wrote: I'm getting the following error: Smarty error: unable to read template resource: "index.tpl" in /var/www/mydomain/httpdocs/smartyfiles/Smarty.class.php on line 589 I can get Smarty to work when all of my scripts reside in the top level directory that includes my template and template_c directories. However I am trying to create a subdirectory (i.e. an "admin" directory). I am then trying to refer back to my Smarty directories but it doesn't seem to like what I am doing. For instance I am using the following statement in a file titled index.tpl that resides in my admin directory which is on the same level as my smartyfiles directory and templates and templates_c directories... require("../smartyfiles/Smarty.class.php"); -- Monte Ohrt <monte@ispi.net> -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php