在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; ?>
觉得文章有用就打赏一下文章作者
微信扫一扫打赏
![](/skin/images/wxskm.jpg)