张文保的博客
张文保 · Paul Zhang

Engineering the Future
功不唐捐,玉汝于成

Typecho分类输出默认链接CSS样式修改

Typecho分类输出默认的样式是有ul、li的列表样式的html,如下:

<ul class="widget-list"><li class="category-level-0 category-parent"><a href="">产品</a>
<ul class="widget-list">
<li class="category-level-1 category-child category-level-odd"><a href="">产品1</a></li>
<li class="category-level-1 category-child category-level-odd"><a href="">产品2</a></li>
</ul>

</li><li class="category-level-0 category-parent"><a href="">新闻</a>
<ul class="widget-list">
<li class="category-level-1 category-child category-level-odd"><a href="">新闻1</a></li>
<li class="category-level-1 category-child category-level-odd"><a href="">新闻2</a></li>
</ul>

</li></ul>

 

我们可以通过修改调用函数,输出以下不带列表的链接样式:

<a class="category-level-0 category-parent" href="">产品</a>
<a class="category-level-1 category-child category-level-odd" href="">产品1</a>
<a class="category-level-1 category-child category-level-odd" href="">产品2</a>
<a class="category-level-0 category-parent" href="">新闻</a>
<a class="category-level-1 category-child category-level-odd" href="">新闻1</a>
<a class="category-level-1 category-child category-level-odd" href="">新闻2</a>

 

方法是找到以下代码:

<?php $this->widget('Widget_Metas_Category_List')->listCategories('wrapClass=widget-list'); ?>

 

替换为以下代码:

<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while ($category->next()): ?>
<a href="<?php $category->permalink(); ?>"><?php $category->name(); ?></a>
<?php endwhile; ?>

 

如果需要更详细个性的修改,具体的分类输出函数的文件在/var/Widget/Metas/Category/List.php文件里,可以找对应的代码进行详细修改。

TAG标签
Typecho

相关文章
本文标题:《Typecho分类输出默认链接CSS样式修改》
网址:https://zhangwenbao.com/typecho-category-outputs-the-default-link-css-style-modification.html
作者:张文保
发布时间:2017-01-09
许可协议:CC BY-NC-SA 4.0
发表新评论
SSL安全认证