Yii使用smarty模板
发布日期:2021-05-10 09:42:08 浏览次数:12 分类:精选文章

本文共 2099 字,大约阅读时间需要 6 分钟。

���Yii���������������Smarty������������

���������Yii���������������������Smarty���������������������������������������������������������������������

  • ������Smarty������������

    ���Smarty���������������������������protected/extensions���������������������������������������������������application/extensions/smarty���

  • ������CSmarty���������

    ���application/extensions/smarty������������������������������������������CSmarty.php������������������

  • template_dir = SMARTY_VIEW_DIR; $this->compile_dir = SMARTY_VIEW_DIR . self::DIR_SEP . 'template_c'; $this->caching = true; $this->cache_dir = SMARTY_VIEW_DIR . self::DIR_SEP . 'cache'; $this->left_delimiter = '
    '; $this->cache_lifetime = 3600; } public function init() {}}
    1. ������Yii������
      ������protected/config/main.php������������components���������������Smarty���������
    2. 'smarty' => array(    'class' => 'application.extensions.CSmarty',),
      1. ������������������������Smarty
        ���������������Smarty���������������������������������������
      2. public $smarty = '';public function init() {    if (!empty($this->smarty)) {        $this->smarty = Yii::app()->smarty;    } else {        $this->smarty = new CSmarty();        // ���������Smarty���������������������������������������������������        $this->smarty->caching = true;        $this->smarty->cache_lifetime = 3600;    }}
        1. ������Smarty������
          ���������������smarty���������Action���������������������������������
        2. public function actionSomeAction() {    $this->smarty->display('your_template_name.htm');    // ���������getBlockStarted���getBlockEnded������������������������������������}
          1. ������������
            • ������views������������template_c���cache���������������������������������������������
              mkdir -p application/views/template_cmkdir -p application/views/cache
            • Smarty���cache_lifetime������������������������������������������������
            • ���������������������������������������������Smarty���������������������������������������������������������������������
          2. ������������������������������������������Yii������������������������Smarty������������������������������������

    上一篇:Yii定制分页,两种分页方式CLinkPager和CListPager
    下一篇:修改GII生成模板

    发表评论

    最新留言

    表示我来过!
    [***.240.166.169]2025年04月28日 08时38分42秒