<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                >整理時間:2018年9月17日 By w.y.b @Meizi Office [TOC] ## 知識點: 1、視頻列表 2、視頻列表分頁 3、分頁與篩選地址組合 4、列表多條件篩選 ## 一、視頻列表 ### (一)屬性數據表 ``` CREATE TABLE `屬性表名` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `attrtype` varchar(30) NOT NULL COMMENT '屬性分類', `attrname` varchar(50) NOT NULL COMMENT '屬性名稱', `value` smallint(5) NOT NULL DEFAULT '0' COMMENT '屬性值', `listorder` smallint(5) NOT NULL DEFAULT '0' COMMENT '排序', `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '狀態 1:啟用,0:禁用', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; ``` ### (二)后臺處理 ``` // 屬性 $video_list = Db::name('屬性表名')->where('attrtype','video')->select(); $this->assign('video_list',$video_list); $level_list = Db::name('屬性表名')->where('attrtype','level')->select(); $this->assign('level_list',$level_list); ``` ### (三)模板渲染 ``` <div class="feifan123-net"> <span>類型</span> <div class="list_nav j-list-nav" id="j-nav-type0"> <ul> <li class="active"><a href="#"> 全部 </a></li> {volist name="videoattr_list" id="vo"} <li><a href="#"> {$vo.attrname} </a></li> {/volist} </ul> </div> </div> <div class="feifan123-net"> <span>行業</span> <div class="list_nav j-list-nav" id="j-nav-type2"> <ul> <li class="active"><a href="#"> 全部 </a></li> {volist name="level_list" id="vo"} <li><a href="#"> {$vo.attrname} </a></li> {/volist} </ul> </div> </div> ``` ## 二、視頻列表分頁 ### (一)參考網址 >分頁 https://v3.bootcss.com/components/#pagination 為您的網站或應用提供帶有展示頁碼的分頁組件,或者可以使用簡單的翻頁組件。 >最新基于ThinkPHP5.0+BootStrap框架開發的自適應WAP手機端響應式界面博客系統PHP源碼 https://blog.csdn.net/wazyb8/article/details/79401940 >Bootstrap 分頁 http://www.runoob.com/bootstrap/bootstrap-pagination.html >【thinkphp5】 分頁樣式修改 https://www.cnblogs.com/richerdyoung/p/7058952.html >ThinkPHP5.0分頁手冊 http://www.hmoore.net/manual/thinkphp5/154294 >thinkphp5傳參分頁功能無效?解決方案 https://blog.csdn.net/houbin99999/article/details/72768240 ### (二)分頁具體實現 #### 1、后臺處理 ``` public function category(){ //分類ID $id = input('id'); $this->assign('id',$id); // 接收前臺屬性傳參 $attr['channel'] = (int)input('get.channel'); $attr['level'] = (int)input('get.level'); $this->assign('attr',$attr); // 分類屬性 $videoattr_list = Db::name('屬性表')->where('attrtype','video')->select(); $this->assign('videoattr_list',$videoattr_list); // 行業屬性 $level_list = Db::name('屬性表')->where('attrtype','level')->select(); $this->assign('level_list',$level_list); // 視頻列表 $video_list = Db::name('視頻表')->order('id desc')->paginate(10,false,[ 'type' => 'bootstrap', 'var_page' => 'page', ]); $page = $video_list->render(); $this->assign('video_list',$video_list); $this->assign('page',$page); // 自動調用模型視圖 $template = getModInfoById($id,'category_template'); return view('../application/index/view/default/index/' . $template); } ``` #### 2、前端渲染 >類型屬性 ``` <div class="feifan123-net"> <span>類型</span> <div class="list_nav j-list-nav" id="j-nav-type0"> <ul> <li {if condition="empty($attr['channel'])"} class="active" {/if} ><a href="?channel=0&level={$attr.level}"> 全部 </a></li> {volist name="videoattr_list" id="vo"} <li {if condition="$vo.value eq $attr['channel']"} class="active" {/if}><a href="?channel={$vo.value}&level={$attr.level}"> {$vo.attrname} </a></li> {/volist} </ul> </div> </div> ``` >行業屬性 ``` <div class="feifan123-net"> <span>行業</span> <div class="list_nav j-list-nav" id="j-nav-type2"> <ul> <li {if condition="empty($attr['level'])"} class="active" {/if} ><a href="?channel={$attr.channel}&level=0"> 全部 </a></li> {volist name="level_list" id="vo"} <li {if condition="$vo.value eq $attr['level']"} class="active" {/if}><a href="?channel={$attr.channel}&level={$vo.value}"> {$vo.attrname} </a></li> {/volist} </ul> </div> </div> ``` >排序屬性 ``` <div class="feifan123-net bb0"> <span>排序</span> <div class="list_nav j-list-nav"> <ul> <li class="active"><a href="#">最新</a></li> <li><a href="#">最熱</a></li> </ul> </div> </div> ``` ## 三、分頁與篩選地址組合 ### (一)分頁參數組合 #### 1、接收前臺屬性傳參 ``` $attr['channel'] = (int)input('get.channel'); $attr['level'] = (int)input('get.level'); $attr['page'] = (int)input('get.page'); $this->assign('attr',$attr); ``` #### 2、組合參數 ``` $url = '/index/index/category?rand=' . rand(5, 12); if($attr['channel']){ $url .= '&channel=' . $attr['channel']; $query['channel'] = $attr['channel']; } if($attr['level']){ $url .= '&level=' . $attr['level']; $query['level'] = $attr['level']; } if($attr['page']){ $url .= '&page=' . $attr['page']; $query['page'] = $attr['page']; } ``` #### 3、分頁組件調用 ``` $video_list = Db::name('視頻表名')->order('id desc')->paginate(10,false,[ 'type' => 'bootstrap', 'var_page' => 'page', 'query' => $query, // $query 是數組 ]); $page = $video_list->render(); $this->assign('page',$page); ``` ### (二)改進組合 #### 1、自定義索引列表 >思路:改進TP5查詢方法,將數據中的ID作為鍵,原數據作為值,重新建立數組。 ``` // 指定表名 public function table($table){ $this->where = array(); $this->field = '*'; $this->order = ''; $this->table = $table; return $this; } // 指定查詢字段 public function field($field = '*'){ $this->field = $field; return $this; } // 排序 public function order($order){ $this->order = $order; return $this; } // 指定查詢條件 public function where($where = array()){ $this->where = $where; return $this; } // 自定義索引列表 public function cates($index){ $query = Db::name($this->table)->field($this->field)->where($this->where); $this->order && $query = $query->order($this->order); $lists = $query->select(); if(!$lists){ return false; } $results = []; foreach ($lists as $key => $value) { $results[$value[$index]] = $value; } return $results; } ``` #### 2、函數array_keys() 函數返回包含數組中所有鍵名的一個新數組。 如果提供了第二個參數,則只返回鍵值為該值的鍵名。 參考網址:http://www.w3school.com.cn/php/func_array_keys.asp 片段代碼: `<?php if(!in_array($data['label_channel'],array_keys($channel_list))){echo 'class="selected"';}?>` 片段代碼: ``` $data['label_channel'] = (int)input('get.label_channel'); $channel_list = $this->db->table('video_label')->where(array('flag'=>'channel'))->cates('id'); $this->assign('channel_list',$channel_list); ``` ``` <h3>頻道:</h3> <ul class="mod_category_item"> <li <?php if(!in_array($data['label_channel'],array_keys($channel_list))){echo 'class="selected"';}?>> <a href="/index.php/index/index/cate?label_channel={$data.label_channel}&label_charge={$data.label_charge}&label_area={$data.label_area}">全部</a> </li> {volist name="channel_list" id="channel"} <li {if condition="$data.label_channel eq $channel.id"}class="selected"{/if}> <a href="/index.php/index/index/cate?label_channel={$data.label_channel}&label_charge={$data.label_charge}&label_area={$data.label_area}">{$channel.title}</a> </li> {/volist} <li class="close-mod_btn"> <a data-searchpingback-elem="link" data-searchpingback-param="ptype=11" href="javascript:;" j-delegate="action"><em class="vm-inline">收起</em><i class="site-icons ico-explain-t"></i></a> </li> </ul> <div class="openBtn"> <a class="openBtn-txt" href="javascript:;" j-delegate="action"><em class="vm-inline">更多</em><i class="site-icons ico-explain-b"></i></a> </div> </div> ``` ## 四、列表多條件篩選 ### (一)數據表設計 #### 1、屬性表 ``` CREATE TABLE `屬性表名` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `attrtype` varchar(30) NOT NULL COMMENT '屬性分類', `attrname` varchar(50) NOT NULL COMMENT '屬性名稱', `value` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '屬性值', `listorder` smallint(5) NOT NULL DEFAULT '0' COMMENT '排序值', `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '狀態 1:啟用,0:禁用', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; ``` #### 2、視頻表 ``` CREATE TABLE `視頻表名` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主鍵', `catid` int(11) NOT NULL DEFAULT '0' COMMENT '分類ID', `title` varchar(100) NOT NULL DEFAULT '' COMMENT '標題', `keywords` varchar(100) NOT NULL DEFAULT '' COMMENT '關鍵詞', `tags` varchar(255) NOT NULL DEFAULT '' COMMENT 'TAGS', `description` varchar(255) NOT NULL DEFAULT '' COMMENT '摘要', `thumb` varchar(100) NOT NULL DEFAULT '' COMMENT '縮略圖', `username` varchar(20) NOT NULL DEFAULT '' COMMENT '用戶名', `inputtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '發布時間', `url` varchar(100) NOT NULL DEFAULT '' COMMENT 'URL', `status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '狀態', `views` int(11) NOT NULL DEFAULT '0' COMMENT '瀏覽量', `listorder` int(11) NOT NULL DEFAULT '0' COMMENT '排序', `content` text NOT NULL, `video` varchar(255) NOT NULL DEFAULT '', `channel` tinyint(5) unsigned NOT NULL DEFAULT '1' COMMENT '分類屬性', `level` tinyint(5) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; ``` ### (二)組合參數 ``` // 分頁參數組合(數組) $query['channel'] = $attr['channel']; $query['level'] = $attr['level']; $query['page'] = $attr['page']; 模板渲染 <li {if condition="empty($attr['channel'])"} class="active" {/if} ><a href="?channel=0&level={$attr.level}"> 全部 </a></li> {volist name="videoattr_list" id="vo"} <li {if condition="$vo.value eq $attr['channel']"} class="active" {/if}><a href="?channel={$vo.value}&level={$attr.level}"> {$vo.attrname} </a></li> {/volist} ``` ### (三)篩選條件 ``` // 分頁參數組合(數組) $query['channel'] = $attr['channel']; $query['level'] = $attr['level']; $query['page'] = $attr['page']; // 組合條件 $where['status'] = 1; if(!empty($attr['channel'])){ $where['channel'] = $attr['channel']; } if(!empty($attr['level'])){ $where['level'] = $attr['level']; } // 視頻列表 $video_list = Db::name('視頻表名')->where($where)->order('id desc')->paginate(10,false,[ 'type' => 'bootstrap', 'var_page' => 'page', 'query' => $query, ]); ``` ### (四)片段代碼 ``` public function category(){ //分類ID $id = input('id'); $this->assign('id',$id); // 接收前臺屬性傳參 $attr['channel'] = (int)input('get.channel'); $attr['level'] = (int)input('get.level'); $attr['page'] = (int)input('get.page'); $this->assign('attr',$attr); // 分類屬性 $videoattr_list = Db::name('屬性表名`')->where('attrtype','video')->select(); $this->assign('videoattr_list',$videoattr_list); // 行業屬性 $level_list = Db::name('屬性表名')->where('attrtype','level')->select(); $this->assign('level_list',$level_list); // 分頁參數組合(數組) $query['channel'] = $attr['channel']; $query['level'] = $attr['level']; $query['page'] = $attr['page']; // 組合條件 $where['status'] = 1; if(!empty($attr['channel'])){ $where['channel'] = $attr['channel']; } if(!empty($attr['level'])){ $where['level'] = $attr['level']; } // 視頻列表 $video_list = Db::name('視頻表名')->where($where)->order('id desc')->paginate(10,false,[ 'type' => 'bootstrap', 'var_page' => 'page', 'query' => $query, ]); $page = $video_list->render();//p($video_list);die; $this->assign('video_list',$video_list); $this->assign('page',$page); // 自動調用模型視圖 $template = getModInfoById($id,'category_template'); return view('../application/index/view/default/index/' . $template); } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看