<?php
if($this->is('category','default')){
$this->need('default.php');
}else{
$this->need('other.php');
}
?>这个方法也是我们常用的,我们使用文件名和分类名一样的,就自动调用对应的模板,其他的用一个对应。
<?php
if($this->is('category','default')){
$this->need('default.php');
}elseif($this->is('category','technology')){
$this->need('technology.php');
}else{
$this->need('other.php');
}
?>同理这个也是。
<?php
$slugArray = array('default','technology');
foreach($slugArray as $slug){
if($this->is('category',$slug)){
$this->need('default.php');
}else{
$this->need('other.php');
}
}
?>这个是用IF判断的,根据别名来使用不同的模板分类。