hab mich heute mal an diesem Tutroial gewagt... doch ab dem Kapitel Layouts quittiert alles den Dienst...
sobald man die smtemplate.php bearbeitet und die
$this->addTemplateDir...-Zeile hinzufügt und die gibt es einen Parse error, den ich partou nicht finde...
[src=php]
<?php
/* Smarty-Dateien laden */
require_once('smarty/Smarty.class.php');
require_once('smtemplate_config.php');
/* An dieser Stelle können Applikations spezifische Bibliotheken geladen werden
* Bsp: require(bib.lib.php);
* */
class SMTemplate extends Smarty {
/**
* Konstruktor.
* Erzeugt eine neue Smarty-Instanz und konfiguriert die Smarty-Pfade
*/
function __construct(){
parent::__construct();
global $smtemplate_config;
$this->template_dir = $smtemplate_config['template_dir'];
$this->addTemplateDir($smtemplate_config['layouts_dir']);
$this->compile_dir = $smtemplate_config['compile_dir'];
$this->cache_dir = $smtemplate_config['cache_dir'];
$this->config_dir = $smtemplate_config['config_dir'];
}
function render($template, $data = array(), $layout = 'page') {
foreach($data as $key => $value){
$this->assign($key, $value);
}
$content = $this->fetch($template . '.tpl');
$this->assign('__content', $content);
$this->display($layout . '.tpl');
}
}
?>
[/src]
index.php
[src=php]<?php
require_once('lib/smtemplate.php');
$data = array(
'user' => 'Coding Pioneers',
'date' => time()
);
$tpl = new SMTemplate();
$tpl->render('start');
?>[/src]
Error:
Fatal error: Uncaught Error: [] operator not supported for strings in F:\_MyWebServer\htdocs\www\smarty_test\lib\smarty\Smarty.class.php:791 Stack trace: #0 F:\_MyWebServer\htdocs\www\smarty_test\lib\smtemplate.php(23): Smarty->addTemplateDir('layouts') #1 F:\_MyWebServer\htdocs\www\smarty_test\index.php(10): SMTemplate->__construct() #2 {main} thrown in F:\_MyWebServer\htdocs\www\smarty_test\lib\smarty\Smarty.class.php on line 791
Versteh ich das aktuell richtig das er ein Problem mit der zeile "$this->addTemplateDir($smtemplate_config['layouts_dir']);" hat?