[ 已解决 ]关于文章CID的判断问题

讨论程序使用中的问题
回复
头像
十口冂二
帖子: 4
注册时间: 2017年 8月 8日 17:08
联系:

[ 已解决 ]关于文章CID的判断问题

帖子 十口冂二 »

代码: 全选

<?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对比来添加样式,但是并不行,求方法!!谢谢!!!
上次由 十口冂二 在 2017年 11月 2日 18:34,总共编辑 1 次。
头像
十口冂二
帖子: 4
注册时间: 2017年 8月 8日 17:08
联系:

Re: 关于文章CID的判断问题

帖子 十口冂二 »

https://segmentfault.com/q/1010000002507943

<?php if ($categoryPosts->cid == $this->cid): ?> class="on"<?php endif; ?>

已解决!
回复