typecho当前分类active样式

本文共有1274个字,关键词:

问题:typecho分类列表,如何对当前分类增加active样式?

解决:使用$categorys->slug

方法


<ul class="navbar-nav mr-auto">
    <li class="nav-item<?php if($this->is('index')):?> current<?php endif;?>">
        <a class="nav-link" href="<?php $this->options->siteUrl(); ?>">
            <span><?php _e('首页'); ?></span></a>
    </li>
    <?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
    <?php while($categorys->next()): ?>
        <?php if ($categorys->levels === 0): ?>
        <li class="nav-item
            <?php if($this->is('post')):?>
                <?php if($this->category == $categorys->slug):?>
                 current<?php endif;?>
            <?php else:?>
                <?php if($this->is('category', $categorys->slug)):?>
                 current<?php endif;?>
            <?php endif;?>">
            <a class="nav-link" href="<?php $categorys->permalink(); ?>"
               title="<?php $categorys->name(); ?>">
               <span><?php $categorys->name(); ?></span></a>
        </li>
        <?php endif; ?>
    <?php endwhile; ?>
</ul>

参考:ttps://www.psay.cn/code/131.html

版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。
添加新评论
暂无评论