求助修改typecho分类输出的样式
原本默认分类输出后样式
<?php $this->widget('Widget_Metas_Category_List')->listCategories('wrapClass=widget-list'); ?>
<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="">产品1000</a></li>
<li class="category-level-1 category-child category-level-odd"><a href="">产品2000</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 href]的方法
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while ($category->next()): ?>
<a href="<?php $category->permalink(); ?>"><?php $category->name(); ?></a>
<?php endwhile; ?>
我想输出全部为[a href]添加相应class 应该怎么写呢
<a class="category-level-0 category-parent" href="">产品</a>
<a class="category-level-1 category-child category-level-odd" href="">产品1000</a>
<a class="category-level-1 category-child category-level-odd" href="">产品2000</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>
小狐狸D摇篮
10 years, 1 month ago
Answers
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while ($category->next()): ?>
<a class="category-level-<?php if($category->isParent()): ?>0 category-parent<?php else: ?>1 category-child category-level-odd<?php endif;?>" href="<?php $category->permalink(); ?>"><?php $category->name(); ?></a>
<?php endwhile; ?>
isParent() 这个方法应该怎么写呢?
输出这样的结构
<a class="category-level-0 category-parent" href="">产品</a>
Mikan
answered 10 years, 1 month ago