Относно урока на Jooorooo - темплейт система с MySQL

nom3r1

Registered
Създаване на темплейт система с MySQL

Опитвам се да я преправя да се отваря темплейта от тук:
templates/THEME

но работата куца доста. Все един и същ проблем:
Код:
Template->make_filename(): Error - file /index_body.tpl does not exist

Ето и файловете:
свали

Надявам се някой да помогне и да каже къде бъркам. В противен случай, явно ще трябва да си напиша моя система..
 
eLite каза:
index.php:
Код:
$template = new Template('templates/default');
=>
Код:
$template = new Template('templates/THEME');
Така?

под името THEME имах на предвид, името на самия темплейт, в моя случай: default, тоест не е от там проблема
 
Става на въпрос, защото правя всичко както е обяснено в урока и грешката си е една:

Код:
Template->make_filename(): Error - file /test.tpl does not exist

И ме интересува, допусната е грешка в урока или ?
 
Така кажи бре приятелю..
index.php:
Код:
$template->set_rootdir(".");
$template->set_filenames(array("index" => "default/index_body.tpl"));
или
template.php:
Код:
var $root = ".";
 
Код:
$template->set_rootdir("./templates");
Или реализираш конструктор на класа така:
Код:
function __construct($rootpath)
	{
		$this->root = $rootpath;
	}
И описваш обекта така:
Код:
$template = new Template('templates/default');
$template->set_filenames(array("index" => "index_body.tpl"));
 
eLite, готин пак си е същата работа. Остави, ще напиша моя система, благодаря още един път.

А, в момента дава тази грешка.. ;)
Код:
Template->make_filename(): Error - file /templates/default/ does not exist
 
template.php:
Код:
<?php
class Template {
  var $classname = "template";
  var $_tpldata = array();
  var $files = array();
  var $root;
  var $compiled_code = array();
  var $uncompiled_code = array();
  var $output = '';
  var $themeconf = array();
  
	function __construct($rootpath)
	{
		$this->root = $rootpath;
	}
function make_filename($filename){
	if (preg_match('/^[a-z_][^:]/i', $filename) ){
		$filename = $this->root.'/'.$filename;
	}
	if (!file_exists($filename)) {
		die("Template->make_filename(): Error - file $filename does not exist");
	}
return $filename;
}
...
?>
index.php:
Код:
<?php
include('config.php');
include('template.php');
$template = new Template('templates/default');
$template->set_filenames(array("index" => "index_body.tpl"));
$template->assign_vars(array(
"TITLE_SITE" => "Тест сайт",
"LOGO" => "kartinka.jpg",
"CHARSET" => "windows-1251"
));

$query = mysql_query("SELECT * FROM `test`") or die('Error, query failed');
	while($row = mysql_fetch_array($query)){
		$template->assign_block_vars("test",array(
		"ID" => $row['id'],
		"USER" => $row['user'],
		"EMAIL" => $row['email']
		));
	}

$template->pparse('index'); 
?>
И всичко работи повече от перфектно и на Linux-ки, и на Windows-ки хостинг.
 

Back
Горе