企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 知识点: 1、首页幻灯片 2、首页导航标签 3、首页数据 ## 一、首页幻灯片 ### (一)思路分析 1、查看源代码 2、检查元素 ### (二)后台处理 ``` public function index() { // 幻灯片 $slide_list = $this->db->table('slide')->where(array('type'=>0))->lists(); $this->assign('data',$slide_list); return $this->fetch(); } ``` ### (三)模板渲染 ``` <div id="piclist" class="qy-focus-index-list"> <ul class="focus-index-list"> {volist name="data" id="ivo"} <li class="focus-index-item" rseat="fcs_0_p<?php echo $i;?>" style=" opacity: 1;<?php if($i>1){echo 'display: none;';}?>"> <a target="_blank" href="{$ivo.url}" class="focus-index-itemLink"><img src="{$ivo.img}"></a> </li> {/volist} </ul> </div> <div class="qy-focus-side-panel"> <div class="focus-side-inner"> <ul id="txtlist" class="focus-side-list"> {volist name="data" id="vo"} <li class="focus-side-item<?php if($i==1){echo ' selected';}?>"> <a title="{$vo.title}" rseat="{$i}" class="focus-side-itemLink">{$vo.title}</a> </li> {/volist} </ul> </div> </div> ``` ### (四)自动切换 ``` <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> $('.focus-side-itemLink').on('mouseover',function(){ $(this).parent('li').addClass('selected').siblings('li').removeClass('selected'); var i = $(this).attr('rseat'); $('.focus-index-list li[rseat="fcs_0_p'+i+'"]').show().siblings('li').hide(); }); </script> ``` ## 二、首页导航标签 ### (一)后台处理 ``` public function index(){ // 导航标签 $channel_list = $this->db->table('video_label')->where(array('flag'=>'channel'))->order('ord asc')->pages(8); $this->assign('channel_list',$channel_list['lists']); return $this->fetch(); } ``` ### (二)模板渲染 ``` <div id="nav_sec_K1" class="nav-item nav-item-0"> {volist name="channel_list" id="cvo"} {if condition="$i%2 eq 1"} <div class="nav-list"> <div class="nav-list-item"><a target="_blank" rseat="712211_channel_yule" href="/index.php/index/index/cate?label_channel={$cvo.id}" class="nav-list-link">{$cvo.title}</a> </div> <div class="nav-list-item"><a target="_blank" rseat="712211_channel_zixun" href="/index.php/index/index/cate?label_channel=<?php echo $channel_list[$key + 1]['id']?>" class="nav-list-link"><?php echo $channel_list[$key + 1]['title']?></a> </div> </div> {/if} {/volist} </div> ``` ### (三)奇偶循环 $key:是从0开始的 $i:是从1开始的 思路:取模运算,当是奇数的时候,循环输出奇数和偶数内容 ``` {volist name="channel_list" id="cvo"} {if condition="$i%2 eq 1"} <div class="nav-list"> <div class="nav-list-item"><a target="_blank" rseat="712211_channel_yule" href="/index.php/index/index/cate?label_channel={$cvo.id}" class="nav-list-link">{$cvo.title}</a> </div> <div class="nav-list-item"><a target="_blank" rseat="712211_channel_zixun" href="/index.php/index/index/cate?label_channel=<?php echo $channel_list[$key + 1]['id']?>" class="nav-list-link"><?php echo $channel_list[$key + 1]['title']?></a> </div> </div> {/if} {/volist} ``` ## 三、首页数据渲染 前台指定调用条数:offset=0 length=4(从第一条开始,总共调用4条数据) ``` <ul class="qy-mod-ul"> {volist name="today_hot_list" id="thl_vo" offset=0 length=4} <li class="qy-mod-li"> <div class="qy-mod-img horizon"> <div class="qy-mod-link-wrap"> <a href="/index/play?id={$thl_vo.id}" target="_blank" title="{$thl_vo.title}" class="qy-mod-link"> <img src="{$thl_vo.img}" rseat="712211_focus_juchangimage" alt="{$thl_vo.title}" class="qy-mod-cover"> <div class="icon-tl"></div> <div class="icon-bl"></div> </a></div> <div class="title-wrap"><p class="main"> <a target="_blank" title="{$thl_vo.title}" href="/index/play?id={$thl_vo.id}" rseat="712211_focus_juchangtitle" class="link-txt"> {$thl_vo.title} </a> </p></div> </div> </li> {/volist} </ul> ```