代码: 全选
<?php $this->widget('Widget_Archive@myCustomCategory', 'type=category', "slug=$this->category")->to($categoryPosts); ?>
<?php while($categoryPosts->next()):?>
<a href="<?php $categoryPosts->permalink() ?>" <?php if ($categoryPosts->cid() == $this->cid()): ?> class="on"<?php endif; ?>>文章标题</a>
<?php endwhile; ?>
以上代码是我放在文章页面POST.php页面的,用于输出当前文章所属分类的文章输出。
代码: 全选
<?php if ($categoryPosts->cid() == $this->cid()): ?> class="on"<?php endif; ?>
这句代码我是想判断循环里的文章cid和目前打开的文章cid对比来添加样式,但是并不行,求方法!!谢谢!!!