当前位置:首页 > 电脑知识 > 正文内容

怎么可以错过(织梦DEDECMS)织梦栏目页模板,织梦dedeCMS模板首页列表页调用文章中多张图片,织梦dedeCMS模板首页列表页调用文章中多张图片,

sauo3年前 (2022-12-15)电脑知识116

由于图集模型有标签可以使用而文章模型没有,所以我们需要对文章模型做一个二次开发。首先打开/include/extend.func.php文件
在最后一行添加以下代码:
functionGetpic($body){ $getpic =; preg_match_all("/(src)=["|| ]{0,}([^>]*.(gif|jpg|png))/isU",$body,$img_array); $img_array = array_unique($img_array[2]); $img_num=3;//此处数字就是图片数量,你自由设置 $img_array=array_slice($img_array,0,$img_num); if(count($img_array)>0) { foreach($img_array as $key=>$value) { $picname = preg_replace("/["||]{1,}/", , $value); $getpic .="<a href=".$picname." target=_blank><img src=".$picname." border=0/></a>"; } } else { $getpic="<p>没有图片</p>"; } return $getpic; }

ps:$img_num=3;//此处数字就是图片数量

$img_array=array_slice($img_array,0,$img_num);
需要注意的是这里调用的是文章模型中BODY字段,所以需要在文章模型中列表附加字段选项增加body,前台列表调用标签里需要加上addfields=’body’,首页调用标签需要加上channelid=’1’来调用。
搜索列表页页多图展示(此方法只适合文章模型)
打开/include/arc.searchview.class.php文件
找到以下代码
$query ="SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule, act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath FROM `{$this->AddTable}` arc LEFT JOIN `dede_arctype` act ON arc.typeid=act.id WHERE {$this->AddSql} $ordersql LIMIT $limitstart,$row";

然后修改为:

$query ="SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule, act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath FROM `{$this->AddTable}` arc LEFT JOIN `dede_arctype` act ON arc.typeid=act.id LEFT JOIN `dede_addonarticle` adt1 ON arc.id=adt1.aid WHERE {$this->AddSql} $ordersql LIMIT $limitstart,$row"
(window.slotbydup = window.slotbydup || []).push({ id: "u6835052", container: "_96bek913mdb", async: true });

本文链接:http://blog.sauo.top/?id=512 感谢分享!

分享到:

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

版权声明:本文由冬眠先生个人博客发布,如需转载请注明出处。

本文链接:http://blog.sauo.top/?id=512

分享给朋友:

“怎么可以错过(织梦DEDECMS)织梦栏目页模板,织梦dedeCMS模板首页列表页调用文章中多张图片,织梦dedeCMS模板首页列表页调用文章中多张图片,” 的相关文章

干货分享(php file_get_contents curl)php file_get_contents post,php file_get_contents(): SSL operation failed with code 1. OpenSSL Error message.....,php file_get_contents(): SSL operation failed with code 1. OpenSSL Error message.....,

免费领取腾讯云服务器! 在调试php脚本代码时,发现使用 file_get_contents() 函数请求HTTPS的网址链接时出现了报错,其报错代码如下面所示“file_get_contents(): SSL operation failed with...

全程干货(查看php是否启动)查看php是否支持rar解压,查看php是ts版本还是nts版本的方法,查看php是ts版本还是nts版本的方法,

全程干货(查看php是否启动)查看php是否支持rar解压,查看php是ts版本还是nts版本的方法,查看php是ts版本还是nts版本的方法,

免费领取腾讯云服务器! 今天有用户来询问php的ts版本与php的nts版本的区别是什么,怎么去查看自己安装的php服务是ts版本还是nts版本,下面博文就来详细的说一下。 php ts版本与nts版本的区别 php官方提供...

全程干货(php将图片转为对象)php文件怎么转成图片,php将图片转为base64编码格式图片的方法,php将图片转为base64编码格式图片的方法,

免费领取腾讯云服务器! 下面的博文提供两个利用php代码将图片转为base64编码格式图片的方法,分为php转换本地图片为base64图片以及php转换远程图片为base64图片的方法。...

没想到(imagettftext函数)imagettftext函数支持的编码类型,imagettftext(): any2eucjp(): invalid code in input string 错误解决方法,imagettftext(): any2eucjp(): invalid code in input string 错误解决方法,

免费领取腾讯云服务器! 最近在研究关于php生成图片的东西,发现了 imagettftext() 函数中一个不是错误的错误,具体的错误情况如下所示。 错误代码:...

墙裂推荐(js判断ip是否合法)判断ipv4地址是否合法,js代码判断IP地址的合法性(只支持IPV4),js代码判断IP地址的合法性(只支持IPV4),

免费领取腾讯云服务器! 客户定制了一个IPV4格式的IP地址在线查询的工具,需要用户在前台输入IPV4格的IP地址,为了防止用户输入的IPV4格式的IP错误,又减少后端的服务器资源的浪费,就想到了先在前台用JS脚本判断一下,用户输入的IPV4地址是否合法。...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。