多级分类带当前页判断

<li<?php if($this->is('index')):?> class="active"<?php endif; ?>><a href="<?php $this->options->siteUrl(); ?>"><?php _e('Home'); ?>
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php if ($category->have()): ?>
<?php while ($category->next()): ?>

<?php if ($category->levels == 0): ?>
    <?php $children = $category->getAllChildren($category->mid); ?>
    <?php if (empty($children)) :?>
        <li<?php if($this->is('post')):?><?php if($this->category == $category->slug):?> class="active"<?php endif;?><?php else:?><?php if($this->is('category', $category->slug)):?> class="active"<?php endif;?><?php endif;?>><a href="<?php $category->permalink() ?>"><?php $category->name() ?></a></li>
    <?php else : ?>
        <li<?php if($this->is('post')):?><?php if($this->category == $category->slug):?> class="active"<?php endif;?><?php else:?><?php if($this->is('category', $category->slug)):?> class="active"<?php endif;?><?php endif;?>><a href="<?php $category->permalink() ?>"><?php $category->name() ?></a>
            <ul>
                <?php foreach ($children as $child ): ?>
                    <?php $child = $category->getCategory($child) ?>
                    <li<?php if($this->is('post')):?><?php if($this->category == $category->slug):?> class="active"<?php endif;?><?php else:?><?php if($this->is('category', $category->slug)):?> class="active"<?php endif;?><?php endif;?>><a href="<?php echo $child['permalink']; ?>"> <?php echo $child['name']; ?></a></li>
                <?php endforeach ?>
            </ul>
        </li>
    <?php endif ?>
<?php endif ?>

<?php endwhile; ?>
<?php endif ?>

发表新评论