smarty模板 section用法

作者:袖梨 2022-07-02

php文件
                $vo = array();
            $trackback_i =0 ;
            $trackback_query = "SELECT t_id,title,t_datetime,t_excerpt,url,blog_name FROM table_tbacks where t_id='$article' ORDER BY t_datetime LIMIT 0,40";
            $idx = 0;
            $this->_db->query($trackback_query) ;
            while ($trackbacki_m_message = $this->_db->fetch_array($trackback_query))
            {
                $vo[] = $trackbacki_m_message;
                $trackback_i++;
             }
             $this->_tpl->assign('vo',$vo);
             $this->_tpl->assign('trackback_ti',$trackback_i);
//trackback end

            $this->_setTplCommon('g.tpl');
模板文件 g.tpl
<{if $trackback_ti !==0 }>

    trackback引用通告


<{section name=vo loop=$vo}>

感谢<{$vo[vo].title}>引用了本文,来自“<{$vo[vo].blog_name}>”,<{$vo[vo].excerpt}>
[阅读更多细节]
<{/section}>
<{/if}>

相关文章

精彩推荐