帝国cms灵动标签实现循环子栏目数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <? php $bclassid=$GLOBALS[navclassid];//取得本栏目id //取得本栏目下的子栏目 ?> [e:loop={"select classid, classname, classpath from `[!db.pre!]enewsclass` where bclassid='$bclassid' order by `classid` desc ",7,24,0}] < dl class="lbox"> <? php //这里是取得该分类下的有图片的最新数据 $commbook=$empire->fetch1("select title,titlepic,smalltext,titleurl,keyboard,groupid,classid,newspath,filename,id from {$dbtbpre}ecms_news where classid = ".$bqr[classid]." and titlepic!='' order by newstime desc limit 1"); $commbookurl=sys_ReturnBqTitleLink($commbook); ?> < dt > < h5 >< a href="<?=$public_r[newsurl].$bqr[classpath]?>"><?=$bqr[classname]?></ a ></ h5 > < span class="more">< a href="<?=$public_r[newsurl].$bqr[classpath]?>">更多</ a ></ span ></ dt > < dd > < ul class="list"> < li class="p1">< a href="<?=$commbookurl?>" target="_blank">< img src="<?=$commbook[titlepic]?>"></ a >< a href="<?=$commbookurl?>" target="_blank"><?=esub($commbook[title],28)?></ a > < p ><?=esub($commbook[smalltext],64)?>...</ p > </ li > <? php //取得该分类下的最新数据 $newbook=$empire->query("select title,titlepic,smalltext,titleurl,keyboard,newstime,groupid,classid,newspath,filename,id from {$dbtbpre}ecms_news where classid =".$bqr[classid]." order by newstime desc limit 5"); while($r=$empire->fetch($newbook)) { ?> < li >< a href="<?=sys_ReturnBqTitleLink($r)?>" title="<?=$r[title]?>"><?=$r[title]?></ a >< span ><?=date('Y-m-d',$r[newstime])?></ span ></ li > <? php } //显示5条 ?> </ ul > </ dd > </ dl > [/e:loop]< br >< br >< br > |
改进后的代码,解决有三级栏目时无法显示列表问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <?php $bclassid = $GLOBALS [navclassid]; //取得本栏目id //取得本栏目下的子栏目 ?> <div class = "btimg" >[e:loop={ $bclassid ,3,0,1}] <div class = "fmimg item" ><a href= "<?=$bqsr[titleurl]?>" ><img src= "<?=$bqr[titlepic]?>" alt= "<?=$bqsr[title]?>" width= "210px" height= "150px" /></a> <p><a href= "<?=$bqsr[titleurl]?>" ><?=esub( $bqr [title],30)?></a></p></div> [/e:loop]</div> [e:loop={ "select classid, classname, classpath from `[!db.pre!]enewsclass` where bclassid='$bclassid' order by `classid` asc" ,7,24,0}] <?php $classurl =sys_ReturnBqClassname( $bqr ,9); //取得栏目地址 //这里是取得该分类下的有图片的最新数据 $commbook = $empire ->fetch1( "select title,titlepic,smalltext,titleurl,keyboard,groupid,classid,newspath,filename,id from phome_ecms_news where classid = " . $bqr [classid]. " and titlepic!='' order by newstime desc limit 1" ); $commbookurl =sys_ReturnBqTitleLink( $commbook ); ?> <div class = "gl_01" <?php $i ++; if ( $i %2==0){ echo 'id="gl_01"' ;} ?> > <span class = "lm-title" ><?= $bqr [classname]?><a href= "<?=$classurl?>" class = "more" >more</a></span> <div class = "yd" > <!--<dl> <dt><a href= "<?=$commbookurl?>" ><img src= "<?=$commbook[titlepic]?>" width= "108px" height= "85px" /></a></dt> <dd><a href= "<?=$commbookurl?>" ><?= $commbook [title]?></dd> </dl>--> <div class = "list" > <?php //取得该分类下的最新数据 $getsqlclass = $empire ->query( "select * from {$dbtbpre}enewsclass where bclassid='$bqr[classid]'" ); $i =0; $arrclass = array (); while ( $getclass = $empire ->fetch( $getsqlclass )){ $sinclassid = $getclass [ 'classid' ]; $arrclass [ $i ]= $sinclassid ; $i ++; } $arrnavclass = array ( "$bqr[classid]" ); $classimp = implode( "," , array_merge ( $arrnavclass , $arrclass )); $newbook = $empire ->query( "select title,titlepic,smalltext,titleurl,keyboard,newstime,groupid,classid,newspath,filename,id from phome_ecms_news where classid in ($classimp) order by newstime desc limit 6" ); while ( $r = $empire ->fetch( $newbook )) { ?> <?php $color = "#999" ; if (time()- $r [newstime]<=1*24*3600) { $color = "red" ; } ?> <li><a href= "<?=sys_ReturnBqTitleLink($r)?>" title= "<?=$r[title]?>" target= "_blank" ><?=esub( $r [title],40, '...' )?></a><span class = "fr" ><FONT color=<?= $color ?>><?= date ( 'm-d' , $r [newstime])?></FONT></span></li> <?php } //显示5条 ?> </div> </div> <div class = "bj_t" ></div> </div> [/e:loop] |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了