查看内容

循环调用子栏目信息以及头条图片

  • 2020-04-08 18:32
  • 编程人生
  • Views

封面模板 可以实现循环子栏目以及头条调用,但是头条的图片和标题只能用一条,只有使用灵动标签。实现效果如图:

?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}]div class=fengm h3spana href=?=$public_r[newsurl].$bqr[classpath]? target=_blank更多+/a/span?=$bqr[classname]?/h3 div class=fpicbox ul?php//这里是取得该分类下的有图片的最新数据$commbook=$empire-query(select * from [!db.pre!]ecms_news where classid = .$bqr[classid]. and titlepic!= order by newstime desc limit 3);$commbookurl=sys_ReturnBqTitleLink($commbook);while($r=$empire-fetch($commbook)){ ? li class=fpica href=?=sys_ReturnBqTitleLink($r)?img src=?=$r[titlepic]? i?=$r[title]?/i/a/li ?php }?/ul /div ul class=fmnews?php//取得该分类下的最新数据 $newbook=$empire-query(select title,titlepic,smalltext,titleurl,keyboard,newstime,groupid,classid,newspath,filename,id from [!db.pre!]ecms_news where classid =.$bqr[classid]. order by newstime desc limit 5); while($r=$empire-fetch($newbook)){ ? lispan?=date(Y-m-d,$r[newstime])?/spana href=?=sys_ReturnBqTitleLink($r)? title=?=$r[title]??=$r[title]?/a/li ?php } //显示5条? /ul /div [/e:loop]

如果首页改用扩展变量,可以这么做系统-扩展变量-增加一个变量名为title div class=tab_box whitebg?php$bclassid=ReturnPublicAddVar(title);//取得栏目id,系统,扩展变量? div class=tab_buttons ul[e:loop={select classid, classname, classpath from [!db.pre!]enewsclass where classidin $bclassidorder by myorder asc ,0,24,0}]?if($bqno==1){?li class=newscurrenta href=javascrpt::?=$bqr[classname]?/a/li?php}else{? lia href=javascrpt::?=$bqr[classname]?/a/li?}? [/e:loop] /ul /div div class=newstab[e:loop={select classid, classname, classpath from [!db.pre!]enewsclass where classidin $bclassidorder bymyorderasc ,0,24,0}] div class=newsitem div class=newspic ul?php//这里是取得该分类下的有图片的最新数据$commbook=$empire-query(select * fromjxhx_ecms_newswhere classid = .$bqr[classid]. and titlepic!= and isgood=1 order by newstime desc limit 2);$commbookurl=sys_ReturnBqTitleLink($commbook);while($r=$empire-fetch($commbook)) { ? lia href=?=sys_ReturnBqTitleLink($r)?img src=?=$r[titlepic]?span?=$r[title]?/span/a/li?php }? /ul /div ul class=newslist?php//取得该分类下的最新数据 $newbook=$empire-query(select * from jxhx_ecms_newswhere classid =.$bqr[classid]. order by newstime desc limit 5); while($r=$empire-fetch($newbook)) { ? lii/ia href=?=sys_ReturnBqTitleLink($r)? title=?=$r[title]??=esub($r[title],60,...)?/ap?=$r[smalltext]?/p/li ?php } //显示5条 ? /ul /div [/e:loop] /div /div !--tab_box end--

实现效果如图:循环调用扩展变量里面的id号,按照后台顺序排序,myorder,图片调的是头条。列表为5条