原本默认分类输出后样式
<code><?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> </code>
在网上找到一个输出全部为[a href]的方法
<code> <?php $this->widget('Widget_Metas_Category_List')->to($category); ?> <?php while ($category->next()): ?> <a href="<?php%20%24category->permalink();%20?>"><?php $category->name(); ?></a> <?php endwhile; ?> </code>
我想输出全部为[a href]添加相应class 应该怎么写呢
<code><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> </code>
原本默认分类输出后样式
<code><?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> </code>
在网上找到一个输出全部为[a href]的方法
<code> <?php $this->widget('Widget_Metas_Category_List')->to($category); ?> <?php while ($category->next()): ?> <a href="<?php%20%24category->permalink();%20?>"><?php $category->name(); ?></a> <?php endwhile; ?> </code>
我想输出全部为[a href]添加相应class 应该怎么写呢
<code><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> </code>
<code><?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%20%24category->permalink();%20?>"><?php $category->name(); ?></a> <?php endwhile; ?> </code>
isParent() 这个方法应该怎么写呢?
输出这样的结构<a class="category-level-0 category-parent" href="">产品</a>