Próbuję zrobić coś własnego jakiś mały cms... chciał bym w nim wykorzystać smarty 3 zrobiłem coś takiego:
plik index.php
/** * Initialize the system */ require('system' . DIRECTORY_SEPARATOR .'initialize.php'); /** * Class Index */ class Index { /** * Initialize the object */ public function __construct() { } /** * Run the controller */ public function run() { $objTpl->assign('name','Johny'); $objTpl->display('index.tpl'); } } /** * Instantiate controller */ $objIndex = new Index(); $objIndex->run();
plik initialize.php:
** * Define root path to Synthx installation */ /** * Include functions, constants and interfaces */ require(S6X_ROOT . 'system' . DS . 'functions.php'); require(S6X_ROOT . 'system' . DS . 'constants.php'); require(S6X_ROOT . 'system' . DS . 'interface.php'); /** * Load the Smarty class file and create an instance. */ require(S6X_ROOT . 'plugins' . DS . 'smarty' . DS . 'Smarty.class.php'); $objTpl = new Smarty(); $objTpl->setTemplateDir(S6X_ROOT . 'templates' . DS); $objTpl->setCompileDir(S6X_ROOT . 'templates_c' . DS); $objTpl->setConfigDir(S6X_ROOT . 'system' . DS . 'config' . DS); $objTpl->setCacheDir(S6X_ROOT . 'system' . DS . 'tmp' . DS); $objTpl->left_delimiter = '<!--{'; $objTpl->right_delimiter = '}-->'; $objTpl->debugging = true; $objTpl->caching = true; $objTpl->cache_lifetime = '120'; //$objTpl->testInstall();
i mam problem z wczytaniem szablonu... Błąd HTTP 500 (Internal Server Error). Kiedy wklejam do pliku initialize.php dwie linijki z pliku index.php odpowiadające za wyświetlanie szablonu wszystko jest ok... ale takie rozwiązanie mnie nie urządza. Jak to można rozwiązać? Co robię źle może źle wczytuję zmienna do pliku index że jej tam nie widzi?
Z góry dziękuję za pomoc.