Salv Posted January 29, 2014 Report Posted January 29, 2014 Sveiciens! Vajadzīgs padoms. Kodu, kas izsauc Smarty bibliotēku ievietoju funkcijā (pirms tam viss strādāja kā vajag). Kas man vēl būtu jāpievieno, lai funkcija nostrādātu korekti? <?php //functions.php function call_smarty(){ require_once('../Smarty/Smarty.class.php'); $smarty = new Smarty(); $smarty->setTemplateDir('/web/www.example.com/smarty/templates'); $smarty->setCompileDir('/web/www.example.com/smarty/templates_c'); $smarty->setCacheDir('/web/www.example.com/smarty/cache'); $smarty->setConfigDir('/web/www.example.com/smarty/configs'); } ?> //index.php <?php // put full path to Smarty.class.php require_once ('functions/functions.php'); call_smarty(); $smarty->display('views/header.tpl'); $smarty->display('views/sidebar.tpl'); $smarty->display('views/main.tpl'); $smarty->display('views/footer.tpl'); ?> Quote
briedis Posted January 29, 2014 Report Posted January 29, 2014 function call_smarty(){ ... return $smarty; } $smarty = call_smarty(); $smarty->... Quote
rpr Posted January 29, 2014 Report Posted January 29, 2014 Mainās pathi. bija '../Smarti', bet tagad ir 'functions/../Smarti' Quote
briedis Posted January 29, 2014 Report Posted January 29, 2014 Jap, ieteikums vienmēr lietot absolūtos ceļus. Nodefinē index.php: define('DIR', dirname(__FILE__) . '/'); Un tad vienmēr izmanto: inlcude DIR . 'libs/blabla.php'; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.