excuteView 其实就是一个简化了的getview和assign,excuteView 传两个参数进去,一个模板,一个你要赋值的数组。类似下面
1 2 3 4 5 | $data=array( 'title'=>'fleaphp', 'content'=>'smarty', ); $this->_excuteView ('index.tpl',$data); |
getView 是首先获得一个smarty对象,然后你自己assign数据,当然其中要使用类似is_cache之类的高级函数,最好还是使用getview. 如果使用getview的话就如下使用
1 2 3 4 | $smarty=$this->_getView(); $smarty->assign('title','fleaphp'); $smarty->assign('content','smarty'); $smarty->display('index.tpl'); |
上面这段代码和excuteView 那一段代码的效果是一样的
但是当你要使用缓存id的时候就应该使用getview啦
1 2 3 4 5 6 | $smarty=$this->_getView(); if(!$smarty->is_cache('cacheid')){ $smarty->assign('title','fleaphp'); $smarty->assign('content','smarty'); } $smarty->display('index.tpl','cacheid'); |
这是在写php嘛?要学习下啦.
你的网页上的元素太多还是怎么的,总觉打开你的页面稍慢点.
回复