文章倒序排列怎么搞?

讨论程序使用中的问题
回复
白天像教授
帖子: 8
注册时间: 2016年 3月 15日 00:53

文章倒序排列怎么搞?

帖子 白天像教授 »

:oops: 磨蹭很久了,找不到合适的办法...
头像
DT27
帖子: 83
注册时间: 2016年 2月 23日 19:48
联系:

Re: 文章倒序排列怎么搞?

帖子 DT27 »

貌似只能自己写 sql 获取,Typecho 里获取文章一般是这么写的:

代码: 全选

$resource = $this->db->query($this->db->select('需要获取的字段')->from('table.contents')
        ->where('type = ?', 'post')
        ->where('table.contents.status = ?', 'publish')
        ->where('table.contents.created < ?', $this->options->gmtTime)
        ->order('table.contents.created', Typecho_Db::SORT_DESC));

其中最后一行就是排序,表示按"created"排序,顺序是降序"Typecho_Db::SORT_DESC",如果你要倒序,也就是升序,用"Typecho_Db::SORT_ASC"就行了。
白天像教授
帖子: 8
注册时间: 2016年 3月 15日 00:53

Re: 文章倒序排列怎么搞?

帖子 白天像教授 »

是的,只能写SQL获取,为了省事我直接改了内核...
头像
ClayMore
帖子: 2483
注册时间: 2007年 11月 29日 02:55
来自: Sleeping Forest
联系:

Re: 文章倒序排列怎么搞?

帖子 ClayMore »

不建议改内核


__________________

新版阿里百秀Alibaixiu主题 v11.1 For Typecho
http://xiu.160.me/
头像
DT27
帖子: 83
注册时间: 2016年 2月 23日 19:48
联系:

Re: 文章倒序排列怎么搞?

帖子 DT27 »

做成插件形式吧。简单方便。改内核后期很麻烦。
回复