在 index.php 中需要正确设置 Smarty 模版引擎选项:

$appInf = array(
    'view' => 'FLEA_View_Smarty',
    'viewConfig' => array(
        'smartyDir'         => APP_DIR . '/Smarty',
        'template_dir'      => APP_DIR,
        'compile_dir'       => APP_DIR . '/templates_c',
        'left_delimiter'    => '{{',
        'right_delimiter'   => '}}',
    ),
);
FLEA::loadAppInf($appInf);

请仔细阅读 Example/Smarty/index.php 中的源代码。


首选的 Smarty 使用方式:
优点:使用灵活,和以前使用 Smarty 完全一致,能够最大限度的利用 Smarty 的增强功能。
缺点:如果更换其它模版引擎,代码修改量较大。

function actionIndex() {
    $smarty =& $this->_getView();
    /* @var $smarty Smarty */
    $smarty->assign('my_var', 'The smarty template engine.');
    $smarty->display('tpl-index.html');
}

Smarty 变量 $my_var 的值: The smarty template engine.

[点击查看另一种使用 Smarty 的方式]