Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> wlasne Template
kicaj
post
Post #1





Grupa: Zarejestrowani
Postów: 1 640
Pomógł: 28
Dołączył: 13.02.2003
Skąd: Międzyrzecz/Poznań

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


Proboje napisac wlasna klase do obslugi szablonow, jakos mi to idzie, (dopiero zaczynam zabawe z klasami) i jest o pewnien problem.

Mam cos takiego:[php:1:4c0c784fef]<?php
class Templates {

function LoadFile($file_id, $file_name, $file_path) {

if(file_exists($file_path.'/'.$file_name)) {

$file_open = fopen($file_path.'/'.$file_name, "r");
$file_content = fread($file_open, filesize($file_path.'/'.$file_name));
fclose($file_open);

$this -> dane = $file_content;

} else {
return false;
}

}

function Content($name, $value) {

$file_display = str_replace('{'.$name.'}', $value, $this->dane);

//W jaki sposob (chyba bedzie potrzeba petla) zrobic zeby
//kazda blok byl podmieniany??

$this -> Replace = $file_display;

}

function Display() {
return $this-> Replace;
}



}

$template = new Templates;
$template -> LoadFile('start', 'start.tpl', '../templates');
$template -> Content('title', 'Tytul Strony');
$template -> Content('body', 'fksdufdut8');
$template -> Content('itp', '<font color=red>gdsg</font>');
echo $template -> Display();
?>[/php:1:4c0c784fef]


--------------------
PHP Developer

"Nadmiar wiedzy jest równie szkodliwy jak jej brak" Émile Zola
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 19.08.2025 - 16:30