帝国cms首页/列表页模板自动获取文章内缩略图/获取文章内1234张缩略图在列表页或者首页显示
时间:2024年04月12日
/来源:网络
/编辑:佚名
参考页面:http://ecms136.78moban.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].'&h=120&w=180&zc=1" alt="'.$bqr[title].'" /></a> ';
}
?>
<li class="listpost_li">
<h2><a href="<?=$bqr[titleurl]?>" title="<?=$bqr[title]?>" 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].'&h=120&w=180&zc=1" alt="'.$bqr[title].'" /></a> ';
}
?>
<li class="listpost_li">
<h2><a href="<?=$bqr[titleurl]?>" title="<?=$bqr[title]?>" 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].'&h=120&w=180&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>
Select CodeCopy
列表页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].'&h=120&w=180&zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
<h2><a href="[!--titleurl--]" title="[!--oldtitle--]" 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].'&h=120&w=180&zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
<h2><a href="[!--titleurl--]" title="[!--oldtitle--]" 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].'&h=120&w=180&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>';
}
首页使用代码参考:
<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].'&h=120&w=180&zc=1" alt="'.$bqr[title].'" /></a> ';
}
?>
<li class="listpost_li">
<h2><a href="<?=$bqr[titleurl]?>" title="<?=$bqr[title]?>" 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].'&h=120&w=180&zc=1" alt="'.$bqr[title].'" /></a> ';
}
?>
<li class="listpost_li">
<h2><a href="<?=$bqr[titleurl]?>" title="<?=$bqr[title]?>" 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].'&h=120&w=180&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>
Select CodeCopy
列表页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].'&h=120&w=180&zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
<h2><a href="[!--titleurl--]" title="[!--oldtitle--]" 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].'&h=120&w=180&zc=1" alt="[!--oldtitle--]" /></a> ';
}
$listtemp='<li class="listpost_li">
<h2><a href="[!--titleurl--]" title="[!--oldtitle--]" 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].'&h=120&w=180&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>';
}
新闻资讯 更多
- 【帝国cms教程】帝国cms首页/列表页模板自动获取文章内缩略图/获取文章内1234张缩略图在列表页或者首页显示04-12
- 【帝国cms教程】帝国cms调用当前父栏目下的所有子栏目,如果是终极栏目则调用同级栏目!04-12
- 【帝国cms教程】帝国cms栏目批量修改增加“是否生成”选项04-12
- 【帝国cms教程】帝国cms同步生成插件手机端分页样式修改04-12
- 【帝国cms教程】宝塔面板帝国cms全站伪静态后台输入admin显示404/nginx伪静态排除指定目录伪静态规则设置04-12
- 【帝国cms教程】帝国cms7.5附表如何分表/分表教程04-12
- 【帝国cms教程】帝国CMS利用百度分词来生成关键字并增加“复制到TAGS”按钮04-12
- 【帝国cms教程】帝国cms反馈表单的制作/封面模板开发反馈表单/单选下拉/复选框反馈表单开发教程04-12
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8帝国cms后台登录出现”您还未登录”怎么解决?
- 9织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法