//判断分类或标签是否过滤(notShowCategory/notShowTags 需要过滤的 分类/标签 ID)
//value:分类或标签ID 
//type:0为分类 1为标签
function isShow($value, $type) {
    $notShowCategory = array("10", "11", "12");
    $notShowTags = array("10", "11", "12");
    if ($type == 0) {
        $notShowId = $notShowCategory;
    } else if ($type == 1) {
        $notShowId = $notShowTags;
    }
    if (!in_array($value, $notShowId, true)) {
        return true;
    } else {
        return false;
    }
}

举例一:

$this->widget('Widget_Metas_Category_List')->to($categorys);
while($categorys->next()):
if ($categorys->levels == 0 && isShow($categorys->mid,0)):
$children = $categorys->getAllChildren($categorys->mid);

举例二:

<?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
<?php while($categorys->next()): ?>
<?php if (isShow($categorys->mid,0)): ?>
<li><a href="<?php $categorys->permalink() ?>"><?php $categorys->name()?> <?php $categorysList?></a></li>
<?php endif; ?>
<?php endwhile; ?>

举例三:

<?php $this->widget('Widget_Metas_Tag_Cloud', 'ignoreZeroCount=1&limit=30')->to($tags); ?>
<?php if($tags->have()): ?>
<?php while($tags->next()): ?>
<?php if (isShow($tags->mid,1)): ?>
<li><a href="<?php $tags->permalink(); ?>"><?php $tags->name(); ?></a></li>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
<li>暂无标签</li>
<?php endif; ?>

Last modification:August 21st, 2019 at 04:50 pm
如果觉得我的文章对你有用,请随意赞赏