当前位置:首页 > 文章 > 帝国CMS > 正文内容

帝国cms首页/列表页模板自动获取文章内缩略图/获取文章内1234张缩略图在列表页或者首页显示

3年前 (2022-10-22)帝国CMS8789

帝国cms首页/列表页模板自动获取文章内缩略图/获取文章内1234张缩略图在列表页或者首页显示

参考页面:http://ecms136.cncobo.com/

首页使用代码参考:

<ul id="divMain">
          <?
          $sql=$empire->query("select * from {$dbtbpre}ecms_news order by id desc limit 30");
          while($bqr=$empire->fetch($sql)){
              $bqsr=sys_ReturnEcmsLoopStext($bqr);
              $bqno++;
          

          $fr=$empire->fetch1("select newstext,infotags from {$dbtbpre}ecms_news_data_{$bqr[stb]} where id='$bqr[id]'");
          $neirong=$fr['newstext'];
          $imgcount=substr_count($neirong,"<img");

          $neirong=preg_replace("@<iframe(.*?)</iframe>@is","",$neirong); 
          $neirong=str_replace("$public_r[newsurl]","/","$neirong");
          $neirong=stripslashes($neirong);

          $match=='';
          $pattern='/<[img|IMG].*?src=\"(.*?(?:[\.gif|\.jpg|\.png]))\".*?>/';
          preg_match_all($pattern,$neirong,$match); 

          if($match[1][0]==''){
          $pattern='/<[img|IMG].*?src=\\\\"(.*?(?:[\.gif|\.jpg|\.png]))\\\\".*?>/';
          preg_match_all($pattern,$neirong,$match); 
          }

          $cl=$empire->fetch1("select classname from {$dbtbpre}enewsclass where classid='$bqr[classid]'");
          $classname=$cl['classname'];

          $infotags=$fr['infotags'];
          $r_tag=explode(",",$infotags);
          for($i=0;$i<count($r_tag);$i++){
            if($r_tag[$i]){
              $tagslink=$public_r[newsurl].'e/tags/?tagname='.$r_tag[$i];
              $tags.="<a href='$tagslink' target='_blank' rel='tag'>".$r_tag[$i]."</a>";
            }
          }

          $tmpimg4='';
          $tmpimg3='';
          $tmpimg1='';
          ?>

          <?
          if($imgcount>3){
            for($j=0;$j<4;$j++){
              $tmpimg4.=' <a href="'.$bqr[titleurl].'"><img src="'.$public_r[newsurl].'e/extend/timthumb.php?src='.$match[1][$j].'&amp;h=120&amp;w=180&amp;zc=1" alt="'.$bqr[title].'" /></a> ';
            }
          ?>
            <li class="listpost_li">
              <h2><a href="<?=$bqr[titleurl]?>"  target="_blank">444<?=$bqr[title]?></a></h2>
              <div class="moreimg"> <?=$tmpimg4?> </div>
              <div class="moreinfo"> <span class="on"><a href="<?=$bqsr[classurl]?>"><?=$classname?></a></span> <span class="on"><?=date('Y-m-d',$bqr[newstime])?></span> <span>阅读(<?=$bqr[onclick]?>)</span> <span><?=$tags?></span> </div>
            </li>
          <?}?>

          <?
          if($imgcount==3){
            for($j=0;$j<3;$j++){
              $tmpimg3.=' <a href="'.$bqr[titleurl].'"><img src="'.$public_r[newsurl].'e/extend/timthumb.php?src='.$match[1][$j].'&amp;h=120&amp;w=180&amp;zc=1" alt="'.$bqr[title].'" /></a> ';
            }
          ?>
            <li class="listpost_li">
              <h2><a href="<?=$bqr[titleurl]?>"  target="_blank">333<?=$bqr[title]?></a></h2>
              <div class="moreimg"> <?=$tmpimg3?> <a href="<?=$bqr[titleurl]?>" class="picture-more">查看详情 ></a></div>
              <div class="moreinfo"> <span class="on"><a href="<?=$bqsr[classurl]?>"><?=$classname?></a></span> <span class="on"><?=date('Y-m-d',$bqr[newstime])?></span> <span>阅读(<?=$bqr[onclick]?>)</span> <span><?=$tags?></span> </div>
            </li>
          <?}?>

          <?
          if($imgcount<3&&$imgcount>0){
            for($j=0;$j<1;$j++){
            $tmpimg1.=' <a href="'.$bqr[titleurl].'"><img src="'.$public_r[newsurl].'e/extend/timthumb.php?src='.$match[1][$j].'&amp;h=120&amp;w=180&amp;zc=1" alt="'.$bqr[title].'" /></a> ';
            }
          ?>
            <li class="listpost_li">
              <div class="img"> <?=$tmpimg1?> </div>
              <div class="info">
                <h2><a href="<?=$bqr[titleurl]?>" target="_blank">222<?=$bqr[title]?></a></h2>
                <div class="moreinfo"> <span class="on"><a href="<?=$bqsr[classurl]?>"><?=$classname?></a></span> <span class="on"><?=date('Y-m-d',$bqr[newstime])?></span> <span>阅读(<?=$bqr[onclick]?>)</span> <span><?=$tags?></span> </div>
              </div>
            </li>
          <?}?>

          <?
          if($imgcount<1){
          ?>
            <li class="listpost_li">
              <div class="info" style="margin-left: 0px;">
                <h2><a href="<?=$bqr[titleurl]?>" target="_blank">000<?=$bqr[title]?></a></h2>
                <div class="moreinfo"> <span class="on"><a href="<?=$bqsr[classurl]?>"><?=$classname?></a></span> <span class="on"><?=date('Y-m-d',$bqr[newstime])?></span> <span>阅读(<?=$bqr[onclick]?>)</span> <span><?=$tags?></span> </div>
              </div>
            </li>
          <?}?>

          <?}?>
        </ul>

列表页list.var内代码参考:

$fr=$empire->fetch1("select newstext,infotags from {$dbtbpre}ecms_news_data_{$r[stb]} where id='$r[id]'");
$neirong=$fr['newstext'];
$imgcount=substr_count($neirong,"<img");

$neirong=preg_replace("@<iframe(.*?)</iframe>@is","",$neirong); 
$neirong=str_replace("$public_r[newsurl]","/","$neirong");

$match=='';
$pattern='/<[img|IMG].*?src="(.*?(?:[\.gif|\.jpg|\.png]))".*?[\/]?>/';
preg_match_all($pattern,$neirong,$match); 

if($match[1][0]==''){
$pattern='/<[img|IMG].*?src=\\\\"(.*?(?:[\.gif|\.jpg|\.png]))\\\\".*?[\/]?>/';
preg_match_all($pattern,$neirong,$match); 
}

$cl=$empire->fetch1("select classname from {$dbtbpre}enewsclass where classid='$r[classid]'");
$classname=$cl['classname'];

$infotags=$fr['infotags'];
$r_tag=explode(",",$infotags);
for($i=0;$i<count($r_tag);$i++){
	if($r_tag[$i]){
		$tagslink=$public_r[newsurl]."e/tags/?tagname=".$r_tag[$i];
		$tags.="<a href='$tagslink' target='_blank' rel='tag'>".$r_tag[$i]."</a>";
	}
}
if($imgcount>3){
for($j=0;$j<4;$j++){
$tmpimg4.=' <a href="[!--titleurl--]"><img src="'.$public_r[newsurl].'e/extend/timthumb.php?src='.$match[1][$j].'&amp;h=120&amp;w=180&amp;zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
            <h2><a href="[!--titleurl--]"  target="_blank">[!--title--]</a></h2>
            <div class="moreimg"> '.$tmpimg4.' </div>
            <div class="moreinfo"> <span class="on"><a href="[!--this.classlink--]">'.$classname.'</a></span> <span class="on">[!--newstime--]</span> <span>阅读([!--onclick--])</span> <span>'.$tags.'</span> </div>
          </li>';
}
if($imgcount==3){
for($j=0;$j<3;$j++){
$tmpimg3.=' <a href="[!--titleurl--]"><img src="'.$public_r[newsurl].'e/extend/timthumb.php?src='.$match[1][$j].'&amp;h=120&amp;w=180&amp;zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
            <h2><a href="[!--titleurl--]"  target="_blank">[!--title--]</a></h2>
            <div class="moreimg"> '.$tmpimg3.' <a href="[!--titleurl--]" class="picture-more">查看详情 ></a></div>
            <div class="moreinfo"> <span class="on"><a href="[!--this.classlink--]">'.$classname.'</a></span> <span class="on">[!--newstime--]</span> <span>阅读([!--onclick--])</span> <span>'.$tags.'</span> </div>
          </li>';
}
if($imgcount<3){
for($j=0;$j<1;$j++){
$tmpimg1.=' <a href="[!--titleurl--]"><img src="'.$public_r[newsurl].'e/extend/timthumb.php?src='.$match[1][$j].'&amp;h=120&amp;w=180&amp;zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
            <div class="img"> '.$tmpimg1.' </div>
            <div class="info">
              <h2><a href="[!--titleurl--]" target="_blank">[!--title--]</a></h2>
              <div class="moreinfo"> <span class="on"><a href="[!--this.classlink--]">'.$classname.'</a></span> <span class="on">[!--newstime--]</span> <span>阅读([!--onclick--])</span> <span>'.$tags.'</span> </div>
            </div>
          </li>';
}
if($imgcount<1){
$listtemp='<li class="listpost_li">
            <div class="info" style="margin-left: 0px;">
              <h2><a href="[!--titleurl--]" target="_blank">[!--title--]</a></h2>
              <div class="moreinfo"> <span class="on"><a href="[!--this.classlink--]">'.$classname.'</a></span> <span class="on">[!--newstime--]</span> <span>阅读([!--onclick--])</span> <span>'.$tags.'</span> </div>
            </div>
          </li>';
}

 

扫描二维码推送至手机访问。

版权声明:本文由蓝博发布,如需转载请注明出处。

本文链接:https://www.blueboss.cn/p/713.shtml

“帝国cms首页/列表页模板自动获取文章内缩略图/获取文章内1234张缩略图在列表页或者首页显示” 的相关文章

帝国cms灵动标签同时调用头条和推荐

帝国cms灵动标签同时调用头条和推荐

帝国cms灵动标签同时调用头条(1级、2级)、推荐(1级、2级)方法1、同时调用头条(1级、2级)、推荐(1级、2级) [e:loop={0,10,3,0,'isgood=1 or firsttitle=1 orisgood=2 or firsttitle=2'}] <a href="<...

帝国cms内容页显示标题加粗颜色等属性

帝国cms内容页显示标题加粗颜色等属性

每条信息的标题设置了不同的颜色,这些在列表页自动能显示出来了。 但是,在内容页用[!--title--]只能显示出标题文字,用什么代码能让内容页也能显示出设置好的标题的颜色? 在内容页模板找到[!--title--]替换为 <?=DoTitleFont($navinfor[titlefont...

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码 [e:loop={"select * from phome_enewsfile_1 where classid='$navinfor[classid]' and id='$navinfor[id]' order by id desc",0,24,0,'','...

帝国CMS列表内容模板(list.var)调用会员头像会员名称等

帝国CMS列表内容模板(list.var)调用会员头像会员名称等

帝国CMS列表内容模板的list.var里面怎么调用会员头像。会员名称,文章标题和文章链接呢?其实方法也很简单,下面帝国cms模板网就来为大家分享: 标签代码如下: $userr=$empire->fetch1("select userpic  from {$dbtbpre}enewsmem...

帝国cms信息反馈开启验证码

帝国cms信息反馈开启验证码

1、后台-系统设置-系统参数设置-信息设置-反馈验证码(后面点开启) 2、信息反馈本身并无放置验证码代码,所先复制评论的验证码代码,后台-模板-评论列表模板-管理评论模板-修改-复制其中的验证码代码 代码如下: 验证码:<input name="key" type="text" size=...

帝国cms专题页面点击率统计代码

帝国cms专题页面点击率统计代码

帝国cms专题页面点击率统计代码 专题访问浏览点击统计 <script src=[!--news.url--]e/public/onclick/?ztid=[!--self.classid--]&enews=dozt></script> 普通内容页 <scr...