Discuz!教程之DIY主题模块增加主题随机排序功能
来源:互联网 发布:钢筋店需要什么软件 编辑:程序博客网 时间:2024/05/19 13:44
如图,添加后的效果,Discuz默认规则里面是没有随机排序的,本教程介绍如果添加随机排序:
修改文件 \source\class\block\forum\block_thread.php
1、参考文件有三个修改点,请按照修改点修改。
2、如果您的网站是gbk的,修改前请务必将block_thread.php文件编码格式转成gbk的,否则前台会乱码。
修改点1
找到代码
'orderby' => array('title' => 'threadlist_orderby','type'=> 'mradio','value' => array(array('lastpost', 'threadlist_orderby_lastpost'),array('dateline', 'threadlist_orderby_dateline'),array('replies', 'threadlist_orderby_replies'),array('views', 'threadlist_orderby_views'),array('heats', 'threadlist_orderby_heats'),array('recommends', 'threadlist_orderby_recommends'),),'default' => 'lastpost'),
修改为
'orderby' => array('title' => 'threadlist_orderby','type'=> 'mradio','value' => array(array('lastpost', 'threadlist_orderby_lastpost'),array('dateline', 'threadlist_orderby_dateline'),array('replies', 'threadlist_orderby_replies'),array('views', 'threadlist_orderby_views'),array('heats', 'threadlist_orderby_heats'),array('recommends', 'threadlist_orderby_recommends'),array('rand', '随机排序'),),'default' => 'lastpost'),
修改点2
找到代码
$orderby= isset($parameter['orderby']) ? (in_array($parameter['orderby'],array('lastpost','dateline','replies','views','heats','recommends')) ? $parameter['orderby'] : 'lastpost') : 'lastpost';修改为
$orderby= isset($parameter['orderby']) ? (in_array($parameter['orderby'],array('lastpost','dateline','replies','views','heats','recommends','rand')) ? $parameter['orderby'] : 'lastpost') : 'lastpost';修改点3
找到代码
$query = DB::query("SELECT DISTINCT t.*$sqlfieldFROM `".DB::table('forum_thread')."` t$sqlfrom WHERE {$maxwhere}t.readperm='0'$sqlAND t.displayorder>='0'ORDER BY t.$orderby DESCLIMIT $startrow,$items;");修改为
if($orderby=='rand'){$query = DB::query("SELECT DISTINCT t.*$sqlfieldFROM `".DB::table('forum_thread')."` t$sqlfrom WHERE {$maxwhere}t.readperm='0'$sqlAND t.displayorder>='0'ORDER BY rand()LIMIT $startrow,$items;");}else{$query = DB::query("SELECT DISTINCT t.*$sqlfieldFROM `".DB::table('forum_thread')."` t$sqlfrom WHERE {$maxwhere}t.readperm='0'$sqlAND t.displayorder>='0'ORDER BY t.$orderby DESCLIMIT $startrow,$items;");}
阅读全文
1 0
- Discuz!教程之DIY主题模块增加主题随机排序功能
- Discuz!论坛教程之DIY调用主题标签TAG修改方法
- 在Launcher3中增加主题切换功能
- 在Launcher3中增加主题切换功能
- 【WP】Chrome主题diy
- Discuz!论坛教程之设置帖子内容编辑后自动提升主题
- Discuz!论坛教程之设置帖子被访问后自动提升主题
- Discuz!论坛教程之设置帖子被收藏后自动提升主题
- Discuz!论坛教程之设置帖子被评分后自动提升主题
- Discuz!论坛教程之设置帖子被支持/反对(顶/踩)后自动提升主题
- Discuz!教程之如何隐藏版块主题列表中的最后回复时间或最后回复人
- Discuz!教程之主题设置图片封面之后不自动跳转回去的问题修改
- Discuz! 7.0 模块调用脚本范例程序 - 主题
- Discuz!DIY完全教程
- apkplug主题切换功能之主题包打包编译-07
- Discuz开发之主题表pre_forum_thread的displayorder字段含义
- Discuz!开发之主题高亮字段highlight解析
- Discuz!开发之修改论坛TAG页面,实现主题按发帖时间倒序排序(新帖在前)
- 深入理解 JavaScript 异步系列(2)—— jquery的解决方案
- GCC 编译 -std简述
- VueJS兄弟组件通信
- Mybatis中<select id="getImages" resultType="java.util.Map">查出的结果顺序
- bootstrapTable动态渲染数据获取
- Discuz!教程之DIY主题模块增加主题随机排序功能
- 梯度(Gradient)与梯度下降法(Gradient Descent)
- 算法设计与应用基础系列7
- 矩阵快速幂DP Darth Vader and Tree : CodeForces
- 牛客小题(js)
- 理解 Memory barrier(内存屏障)
- linux centos7系统的服务器重启,外网ping不通,网卡无法启动的解决办法!
- 书上没有详细列出的几个函数归纳
- 分配mysql用户权限以及修改密码