|
|
|
| При установке Smarty сделала вот что:
1. Скопировала директорию libs в корень проекта (абс. путь - C:\WebServers\home\myproject.ua\www\libs\)
2. Создала в ней директорию smarty, в ней - 4 директории cache, configs, templates, templates_с.
3. Подключила директории скриптом setup.php (расположен в libs\)
<?php
require ("Smarty.class.php");
class Smarty_M extends Smarty {
function Smarty_WebImg() {
$this->Smarty();
$this->template_dir = "smarty/templates/";
$this->compile_dir = "smarty/templates_c/";
$this->config_dir = "smarty/configs/";
$this->cache_dir = "smarty/cache/";
}
}
?>
|
4. Создала файл шаблона и поместила его в templates:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 //EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<title>{$title}</title>
</head>
<body>
<h1>Сайт MyProject.ua</h1>
<p>Все работает!</p>
</body>
</html>
|
5. В корне проекта создала проверочный smarty.php
<?php
require ("libs/setup.php");
$smarty = new Smarty_M;
$smarty->assign("title", "Сайт MyProject.ua - главная страница");
$smarty->display("index.tpl");
?>
|
Выдает ошибку:
Warning: Smarty error: unable to read resource: "index.tpl" in s:\home\myproject.ua\www\libs\Smarty.class.php on line 1092 | |
|
|
|
|
|
|
|
для: Лена
(14.05.2008 в 11:44)
| | типа не могу открыть файл index.tpl он у вас вообще в наличии есть? | |
|
|
|
|
|
|
|
для: Лена
(14.05.2008 в 11:44)
| | Попробуйте абсолютные пути прописать до папок смарти:
<?
$root = $_SERVER['DOCUMENT_ROOT'].'/libs/';
$this->template_dir = $root."smarty/templates/";
$this->compile_dir = $root."smarty/templates_c/";
$this->config_dir = $root."smarty/configs/";
$this->cache_dir = $root."smarty/cache/";
?>
|
Да, и этот код нужно в конструкторе класса Smarty_M вызывать, либо непосредственно вызвать метод Smarty_WebImg(). Это надо чтобы инициализировать эти пути.
<?php
require ("libs/setup.php");
$smarty = new Smarty_M;
$smarty->Smarty_WebImg();
$smarty->assign("title", "Сайт MyProject.ua - главная страница");
$smarty->display("index.tpl");
?>
|
| |
|
|
|