正务库

typecho判断当前分类是否有子分类

时间:2年前   游览量:471    标签: nbsp    quot    gt    php    没有    widget   

在sf上看到的是这个样子的

<?php
$this->widget("Widget_Metas_Category_List")->to($category);
while($category->next()) {
    $noChild = count($category->children) === 0;
    print_r( $noChild ? "没有子分类" : "有子分类" );
}
?>


我发现并不适合用于调用,所以改成下面判断方式

 <?php if(count($category->children) === 0): ?>
没有子分类<?php else: ?>
有子分类<?php endif; ?>