Typecho 怎么实现当前分类目录的区别显示?

发布于 2022-08-24 00:37:07 字数 213 浏览 19 评论 0

问题详见博客http://hellowiki.com(这个typecho主题看起来很舒服)。
搜索了很久没找到实现侧边栏效果的解决办法。未询问设计师Fen本人。各位可请帮忙?麻烦了

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雄赳赳气昂昂 2022-08-31 00:37:07

这里对$this->widget('Widget_Metas_Category_List')进行了修改,判断当前分类目录的关键是<?php if($this->is('category', $categories->slug)): ?> class="current"<?php endif; ?>这句,如果是当前分类,则该分类导航的 html 中加上class="current",而 .current 这个 css 样式就由你自定义了。

模板中 PHP 代码如下:

<?php $this->widget('Widget_Metas_Category_List')->to($categories); ?>
<?php while($categories->next()): ?>
    <li<?php if($this->is('category', $categories->slug)): ?> class="current"<?php endif; ?>><a href="<?php $categories->permalink(); ?>"><?php $categories->name(); ?></a><i>⇒ <?php $categories->count(); ?> posts</i></li>
<?php endwhile; ?>
我的痛♀有谁懂 2022-08-31 00:37:07
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>

主要是操作$category变量,加上判断语句即可

生生漫 2022-08-31 00:37:07

@fen 谢谢,祝冬春愉快。代码完全照搬顺利完成了。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文