分享
  • 收藏
  • 举报
    X
    关于listpage标签 给后面的人排坑
    1327
    6

    我们开发很多时候会有置顶 精华这种功能

    精华就不说了

    我就说说置顶

    你会发现你使用listpage标签无法去在order中添加你的置顶条件

    并且where条件也无法添加

    因为官方在这里添加了一层过滤

    如果你要添加  请修改


    \application\common\controller\index\C.php

    查找

    if (!in_array($order, ['id','create_time','list','rand()','view'])) {
                if(empty($order) || table_field($this->model->getTableByMid($mid),$order)==false){
                    $order = 'list';
                }
            }

    替换成

     $order || $order = 'list';


    改完了之后你会发现置顶的条件已经添加到order中

    但是 如果你标签中的order写法是:

    {qb:listpage name="news_list_page_listdata01" type="cms" rows="10" order="istop desc ,list desc" by="desc" where="create_time<$time" }


    那么你会发现你的分页是不可用的

    order="istop desc,list desc" 在tag标签中可以这么使用

    但是在listpage标签中 你想分页 那么 请先升级

    如果你后台二次开发文件过多

    那么你只需要改如下几个文件

    这些文件不仅仅可以修改order传参的问题 还可以添加where传参的问题

    更新时间为2018-07-25
    /application/common/controller/index/C.php 

    /application/common.php 

    /application/index/controller/LabelShow.php

    /application/common/taglib/Qb.php


    这个更新后  你会发现 

    {qb:listpage name="news_list_page_listdata01" type="cms" rows="10" order="istop desc ,list desc" by="desc" where="create_time<$time" }


    还是不可以使用  惊不惊喜意不意外!  那是不是白更新了呢?

    并不是。

    因为你还需要修改一个文件

    \application\index\controller\LabelShow.php

    修改一下函数

    public function get_listpage_ajax_url


    整个函数换成下面的

        public function get_listpage_ajax_url($tag_name=''){
            $cfg = self::$list_page_cfg[$tag_name];
            if ($cfg['where']) {
                $cfg['where'] = mymd5($cfg['where']);   //避免用户恶意修改
            }
            $_getA = [];
            foreach($cfg AS $key=>$value){
                if ($value && !preg_match("/^([-\w]+)$/i", $value)) {
                    $_getA[$key] = $value;
                    unset($cfg[$key]);
                }
            }
            $_get = http_build_query($_getA);    //路由无法正确解释带有空格之类的内容,所以要改用GET
            echo  iurl(  config('system_dirname').'/content/ajax_get',  $cfg )."?$_get&page=";
        }


     从此以后  你会发现 你的代码既可以支持where 也可以支持order 传参


    10
    赏礼
    赏钱
    收藏
    点击回复
        全部留言
    • 6
    • verycong 风格开发者 消费:118.73元 2018-07-26 14:33 14:336楼

      这个改了就不能升级了吧

      1stFreddy 消费:0元 2018-07-26 16:12
      升级就手动修改啊   我无数次手动修改了  
    0 赏钱 赏礼回复
    • verycong 风格开发者 消费:118.73元 2018-07-26 14:34 14:346楼

      官方升级下,后面带个参数,一种屏敝一种不屏。

      admin 消费:3.03元 2018-07-26 14:58
      改了
    0 赏钱 赏礼回复
    • admin 超级管理员 消费:3.03元 2018-07-26 14:32 14:326楼

      总结得这么仔细.辛苦了

    0 赏钱 赏礼回复
    • qiqi123 普通粉丝 消费:3元 2018-07-26 12:04 12:046楼

      之前没注意看,谢谢提供解决方案

    0 赏钱 赏礼回复
    更多回复
    恢复多功能编辑器
  • 3 1
  • 推荐内容
    扫一扫访问手机版
    请选择要切换的马甲:

     
    网页即时交流
    QQ咨询
    咨询热线
    020-28998648