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

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

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

帝国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://blueboss.cn/p/713.shtml

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

IIS环境下开启TAG伪静态帝国CMS的中文TAG提示此TAG不存在

IIS环境下开启TAG伪静态帝国CMS的中文TAG提示此TAG不存在

用帝国cms制作网站或者搬家后,IIS环境下开启TAG伪静态,帝国CMS的中文TAG提示此TAG不存在,是什么问题呢?解决方案: 打开/e/tags/index.php文件 查找: $tagname=RepPostVar($_GET['tagname']); 修改为 $tagname=RepPo...

帝国CMS几个函数RepPostVarRepPostVar2RepPostStrRepPostStr2的用法

帝国CMS几个函数RepPostVarRepPostVar2RepPostStrRepPostStr2的用法

帝国CMS常用或者经常遇到的几个函数RepPostVar,RepPostVar2,RepPostStr,RepPostStr2的用法! (1)、数字型变量可以用(int)或intval函数处理,例子: $page=(int)$_GET['page']; 或 $page=intval($_GET['p...

帝国CMS内容页字段为空判断的用法

帝国CMS内容页字段为空判断的用法

帝国CMS内容页中,如果某个字段没有填写内容就不显示,填写了就正常显示,这种效果怎么实现? PHP判断实现,代码如下: <?php if($navinfor[字段名]) { ?> 现在的内容 <? } else { ?> 不显示 <? } ?>...

帝国CMS模板中调用用户投稿头像

帝国CMS模板中调用用户投稿头像

帝国CMS列表模板,内容页模板里面怎么调用用户头像呢?或者是用户投稿头像,这个问题怎么实现呢?其实不难,下面帝国cms模板网小编就来告诉大家怎么调用用户头像,一起来学习学习吧:   第一、列表内容模板(list.var) (*) 调用用户投稿的头像方法: $userr=$empire->fe...

帝国CMS模板怎么禁止鼠标右键菜单和复制功能

帝国CMS模板怎么禁止鼠标右键菜单和复制功能

帝国cms模板如何禁止鼠标、鼠标右键和复制功能,这样可以避免一些只知道复制的网站增加原始内容的强度。 正如模板的确认所知,模板中页面的内容从html主体标记中的代码开始。我们只需要另一个代码来实现屏幕上的鼠标右键:oncontextmenu=self.event.returnValue=false...

帝国CMS灵动标签循环调用栏目文章

帝国CMS灵动标签循环调用栏目文章

帝国CMS灵动标签循环调用栏目文章的方法:   具体方法如下:   第一步,增加公共模板变量   代码如下: <div class="newsbox"> [e:loop={"select * from [!db.pre!]enewsclass where classid in (1,2...