我正在尝试使用Smarty设置Slim Framework,但有些事情是非常错误的。
我可以输出模板,但它会使用标记和应该替换标记的数据呈现模板。在.tpl中我有一个标记{#currency#}
,但这也是我在调用test.php / test / 1时打印的内容
我的test.php中有这个
require 'libs/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
use Slim\Slim;
require 'libs/Slim/Extras/Views/Smarty.php';
$app = new Slim(array('view', new \Slim\Extras\Views\SmartyView()));
$app->get('/test/:id', function($id) use ($app) {
$adverts = new Adverts();
$app->render('viewad.tpl', array(
'viewad' => $adverts->viewsinglead($id),
'imagelist' => $adverts->getadimages($id),
'firstimage' => $adverts->getadimage($id)
));
});
$app->run();
在libs / Slim / Extras / Views / Smarty.php中我设置了这个:
public static $smartyDirectory = '/var/www/vhosts/xxxxx.dk/web/libs/smarty/libs';
public static $smartyCompileDirectory = '/templates_c';
public static $smartyCacheDirectory = '/cache';
public static $smartyTemplatesDirectory = '/templates';
答案 0 :(得分:1)
阵列中有错误! 这修好了它:
$app = new Slim(array('view' => new \Slim\Extras\Views\SmartyView()));