Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [smaerty] Dziwna sprawa
lolek09
post
Post #1





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 30.05.2003
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Zainstalowałem smarty, i choć nie zwraca żadnych błędów, to nic nie wyświetla. Po prostu w przeglądarce białe tło i nic więcej.
Ścieżki i prawa do plików są ustawione jak trzeba, bo nie zwraca błędów przy odczytywaniu pliku, templates_c też jest ok, bo tworzy tam plik php.
Źródła:
index.php
[php:1:f93b3e0567]<?php
require('/usr/local/lib/smarty/Smarty.class.php');

$smarty = new Smarty;

$smarty->template_dir = '/var/smarty/templates/';
$smarty->compile_dir = '/var/smarty/templates_c/';
$smarty->config_dir = '/var/smarty/configs/';
$smarty->cache_dir = '/var/smarty/cache/';

$smarty->assign('name','Józek');

$smarty->display('index.tpl');
?>[/php:1:f93b3e0567]
Kod
<HTML>

<HEAD>

</HEAD>

<BODY>

Hello World!<BR>

My name is {$name}

</BODY>

</HTML>


Byłbym wdzięczny, gdyby ktoś potrafił mi pomóc.
?>[/php]
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
[fisher]
post
Post #2





Grupa: Zarejestrowani
Postów: 151
Pomógł: 0
Dołączył: 4.03.2003

Ostrzeżenie: (0%)
-----


Przegladnij logi apache np. /var/log/apache/error_log

pewnie nie ma uprawnien do takich katalogow, a php ma wylaczone raportowanie bledow na stronie

moze uzyj takiej mojej klasy

[php:1:1352598b0c]<?php
require_once('./path_to_smarty/Smarty.class.php');
// Klasa wrapper dziedziczaca ze Smarty
// i ustawiajaca kilka wartosci
// Automagicznie tworzy dla siebie katalogi
class ExtendedSmarty extends Smarty {

var $_settings, $perm, $smarty_dir, $smarty_templates_c, $smarty_template_dir, $smarty_languages, $smarty_cache;

function ExtendedSmarty() {
// Check directory where smarty will store temporary files
$this->_settings = &$GLOBALS['settings'];
$this->perm = 0771;
$this->checktmpdir($this->_settings['tmp_directory'], "smarty", "templates_c", "./languages", "./templates", "cache", $this->perm);

// Make directory for user (directory creates only when not exist)

//
// Run smarty constructor
$this->Smarty();
//
// Set paths for templates, configs and cache folder
$this->template_dir = $this->smarty_template_dir;
$this->compile_dir = $this->smarty_templates_c;
$this->config_dir = $this->smarty_languages;
$this->cache_dir = $this->smarty_cache;
//
// Set smarty variables
$this->caching = true;
// When site goes into production SET false !!! CHANGEME
$this->force_compile = true;
//
$this->debugging_ctrl = "NONE";
// When site goes into production SET false !!! CHANGEME
$this->compile_check = true;
//
//
}
function checktmpdir($tmpdir, $smarty, $templates, $languages, $template_dir, $cache, $perm) {
// check dir name from settings, correct if is wrong
$strLen = strlen($tmpdir);
if($tmpdir[$strLen - 1] == "/") $this->smarty_dir = substr($tmpdir, 0, $strLen - 1);
else $this->smarty_dir = $tmpdir;

// create directory
$this->make_dir($this->smarty_dir);

// check sub-dirs, make if not exist
if(!file_exists($this->smarty_dir . "/" . $smarty))
$this->make_dir($this->smarty_dir . "/" . $smarty);
if(!file_exists($this->smarty_dir . "/" . $smarty . "/" . $templates))
$this->make_dir($this->smarty_dir . "/" . $smarty . "/" . $templates);
$this->smarty_templates_c = $this->smarty_dir . "/" . $smarty . "/" . $templates;
if(!file_exists($this->smarty_dir . "/" . $smarty . "/" . $cache))
$this->make_dir($this->smarty_dir . "/" . $smarty . "/" . $cache);
$this->smarty_cache = $this->smarty_dir . "/" . $smarty . "/" . $cache;
if(file_exists(realpath($languages)))
$this->smarty_languages = realpath($languages);
if(file_exists(realpath($template_dir)))
$this->smarty_template_dir = realpath($template_dir);
}
function make_dir($dir) {
// Recursive create directory
$tmpPieces = explode("/", $dir);
$tmp = "";
for($i=0; $i < count($tmpPieces); $i++){
$tmp .= $tmpPieces[$i] . "/";
if(!file_exists($tmp))
mkdir($tmp, $this->perm);
}
}
}

?>[/php:1:1352598b0c]
a pozniej
[php:1:1352598b0c]<?php
// Zeby miec pewnosc ze wszystko jest ok
error_reporting(E_ALL);
$settings['tmp_directory'] = '/tmp/php';
$smarty = new ExtendedSmarty();
?>[/php:1:1352598b0c]
a dalej juz po staremu ... ;-)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 2.10.2025 - 20:03